68user's page 掲示板

Prev< No. 4035〜4040> Next  [最新発言に戻る] [過去ログ一覧]
No. 4035 # アトヌル 2004/11/04 (木) 19:26:06
始めまして。
sedコマンドで、改行を含む文字列へ変換したいのですが、どのようにすればいいですか?

abcde
------
fgh
ijk

たとえば、abcdeをfgh(改行)ijkとしたい場合、

sed "s/abcde/fghijk/g" file1 > file2
これでは改行無しで置換されてしまいます。
\n,\r\nなど埋め込んでみましたがうまくいきませんでした。

皆さん教えてください、宜しくお願いします。

No. 4036 # 2004/11/04 (木) 19:34:08
Cシェルの中で、コマンドオプションの有無を判断するのには、どのようにIF文を書けば良いですか?
教えてください、よろしくお願いします。

No. 4037 # zsh 2004/11/06 (土) 19:36:04
>>4034 noza
ヒアドキュメントを使うとできた筈ですが
sqlplusの引数でユーザ名とパスワードが必要になるため
お勧めしません。

>>4035 アトヌル
sedでは確か無理だったと思います。
(嘘ついてたらごめんなさい。)

>>4036
コマンドオプションって何ですか?引数の事?

No. 4038 # 68user 2004/11/08 (月) 13:49:29
>>4033 上田
fork の前にシグナルハンドラを設定するのが普通かと思います。でないと、
設定前にシグナルが飛んできたら困りますので。

ただしシグナルハンドラは子プロセスに引き継がれるので、fork 後に
シグナルハンドラを戻すなどの対処が必要です (この例では子プロセスが
SIGCHLD を受けることはないので、どちらでも構わないのですが)。

>>4037 zsh
> ヒアドキュメントを使うとできた筈ですが
ヒアドキュメントでもいいし、別ファイルにしておいて
      sqlplus $user/$pass @hoge.sql
としてもよいです。

> sqlplusの引数でユーザ名とパスワードが必要になるためお勧めしません。
これはまぁいいんじゃないですかね。Perl で Oracle に接続しても
スクリプト中にパスワードを書きますし、Pro*C でもバイナリを
strings すればわかりますし。

No. 4039 # yamaさん [E-mail] 2004/11/08 (月) 21:26:09
yahooオークションの自動ログインシステムをプログラムしていますが、ログインできません。
どなたかご教授願います。以下にソースを掲載しておきます。

import java.net.*;
import java.io.*;

public class post {
    public static void main(String[] args) {
        try {
            int start = 0;
            PrintWriter pw = new PrintWriter
                        (new BufferedWriter(new FileWriter("post.html")));

            // URLクラスのインスタンスを生成
            URL helloURL =
                        new URL("http://login.yahoo.co.jp/config/login");

            // 接続します
            URLConnection con = helloURL.openConnection();
            // 出力を行うように設定します

            con.setDoOutput(true);
            con.setDoInput(true);

            con.setRequestProperty("Cookie","B=banotfp0orfbj&b=2");

            con.setRequestProperty("Accept-Language", "ja");
            con.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)");

            // 出力ストリームを取得
            PrintWriter out = new PrintWriter(con.getOutputStream());

            out.print(".tries=1");
            out.print(".done=http://page7.auctions.yahoo.co.jp/jp/auction/g25311966?");
            out.print(".src=auc");
            out.print("lg=jp");
            out.print(".intl=jp");
            out.print("login=********");
            out.print("passwd=*******");
            out.close();


            // 入力ストリームを取得
            BufferedReader in = new BufferedReader(
                                                                new InputStreamReader(
                                                                con.getInputStream(),"JISAutoDetect"));

            // 一行ずつ読み込みます
            String line;
            while ((line = in.readLine()) != null) {
                // 表示します
                pw.println(line);


            }


            // 入力ストリームを閉じます
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

post.htmlにはログインされた後の商品ページが表示されます(ログインできれば)

No. 4040 # やまさん [E-mail] 2004/11/08 (月) 21:45:49
yahooオークションの自動ログインプログラムを開発していますが、どーしてもログイン
できません。どなたかご教授願います。以下にソースを掲載します。

import java.net.*;
import java.io.*;

public class post {
    public static void main(String[] args) {
        try {
            int start = 0;
            PrintWriter pw = new PrintWriter
                        (new BufferedWriter(new FileWriter("post.html")));

            // URLクラスのインスタンスを生成
            URL helloURL =
                        new URL("http://login.yahoo.co.jp/config/login");

            // 接続します
            URLConnection con = helloURL.openConnection();
            // 出力を行うように設定します

            con.setDoOutput(true);
            con.setDoInput(true);

            con.setRequestProperty("Cookie","B=banotfp0orfbj&b=2");

            con.setRequestProperty("Accept-Language", "ja");
            con.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)");

            // 出力ストリームを取得
            PrintWriter out = new PrintWriter(con.getOutputStream());

            out.print(".tries=1");
            out.print(".done=http://page7.auctions.yahoo.co.jp/jp/auction/g25311966?");
            out.print(".src=auc");
            out.print("lg=jp");
            out.print(".intl=jp");
            out.print("login=******");
            out.print("passwd=*****");
            out.close();


            // 入力ストリームを取得
            BufferedReader in = new BufferedReader(
                                                                new InputStreamReader(
                                                                con.getInputStream(),"JISAutoDetect"));

            // 一行ずつ読み込みます
            String line;
            while ((line = in.readLine()) != null) {
                // 表示します
                pw.println(line);
    

            }


            // 入力ストリームを閉じます
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

なお、post.htmlには正常にログインできれば商品ページのソースを書き込みます。

Prev< No. 4035〜4040> Next  [最新発言に戻る] [過去ログ一覧]