|
始めまして。 sedコマンドで、改行を含む文字列へ変換したいのですが、どのようにすればいいですか? abcde ------ fgh ijk たとえば、abcdeをfgh(改行)ijkとしたい場合、 sed "s/abcde/fghijk/g" file1 > file2 これでは改行無しで置換されてしまいます。 \n,\r\nなど埋め込んでみましたがうまくいきませんでした。 皆さん教えてください、宜しくお願いします。 |
|
Cシェルの中で、コマンドオプションの有無を判断するのには、どのようにIF文を書けば良いですか? 教えてください、よろしくお願いします。 |
|
>>4034 noza ヒアドキュメントを使うとできた筈ですが sqlplusの引数でユーザ名とパスワードが必要になるため お勧めしません。 >>4035 アトヌル sedでは確か無理だったと思います。 (嘘ついてたらごめんなさい。) >>4036 y コマンドオプションって何ですか?引数の事? |
|
>>4033 上田 fork の前にシグナルハンドラを設定するのが普通かと思います。でないと、 設定前にシグナルが飛んできたら困りますので。 ただしシグナルハンドラは子プロセスに引き継がれるので、fork 後に シグナルハンドラを戻すなどの対処が必要です (この例では子プロセスが SIGCHLD を受けることはないので、どちらでも構わないのですが)。 >>4037 zsh > ヒアドキュメントを使うとできた筈ですが ヒアドキュメントでもいいし、別ファイルにしておいて sqlplus $user/$pass @hoge.sql としてもよいです。 > sqlplusの引数でユーザ名とパスワードが必要になるためお勧めしません。 これはまぁいいんじゃないですかね。Perl で Oracle に接続しても スクリプト中にパスワードを書きますし、Pro*C でもバイナリを strings すればわかりますし。 |
|
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にはログインされた後の商品ページが表示されます(ログインできれば) |
|
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には正常にログインできれば商品ページのソースを書き込みます。 |