SlideShare uma empresa Scribd logo
1 de 7
コマンド実行結果の
ログ取得について
  2013年2月6日
    川口 浩司
リダイレクト (sh / bashの場合)
• a.out > text.log
  – 標準出力のみリダイレクト
  – 標準エラー出力はリダイレクトされない
• a.out > text.log 2>&1
  – 標準出力、標準エラー出力ともリダイレクト
  – 「> text.log」「2>&1」を逆にしてはいけない
• a.out 2>&1 | b.sh
  – 標準出力、標準エラー出力とも、パイプにリダイ
    レクト
                                   2
script
$ script
Script started, file is typescript
$ pwd
/home/kawaguchi                   新しいシェル
$ exit
Script done, file is typescript
$ cat typescript
Script started on Tue Feb 5 18:41:57 2013
$ pwd
/home/kawaguchi                    ログの内容
$ exit
Script done on Tue Feb 5 18:41:58 2013
$


                                            3
ターミナルソフト

teraterm    PuTTY




                    4
vi / emacs
【vi】
• :r! a.out
   – 実行結果をカーソル位置に読み取る
• :%! a.out
   – 指定した範囲を外部コマンドに渡して、実行結果で置き換える

【emacs】
• M-! a.out (M-& a.out)
   – 実行結果を新しいバッファ(*Shell Command Output*)に表示
• M-| a.out
   – 選択範囲を外部コマンドに渡す
• C-u M-! a.out
   – 実行結果をカレントバッファに読み込む

                                               5
screen
• GNUによって開発された、フリーな端末多重接続ソ
  フトウェア
• コマンドライン版のウィンドウシステムのようなもの
• ターミナル上で仮想端末を作成する
 $ screen
• スクロールバッファの参照とコピー&ペースト(C-A [、
  SPACE~ENTER、])
• 領域を分割(C-A S、TAB、Q)
• 複数スクリーンの切り替え(C-A C-C、数字、")
• セッションのデタッチ(C-A d)と再接続
 $ screen -r
                             6
tmux
• 「screen」と同様のソフトウェア(BSDライセンス)
• 「terminal multiplexer」の略
• ターミナル上で仮想端末を作成する
 $ tmux
• スクロールバッファの参照とコピー&ペースト(C-B [、
  C-@~C-w、C-B ])
• 領域を分割(C-B "、o、!)
• 複数スクリーンの切り替え(C-B c、数字、w)
• セッションのデタッチ(C-B d)と再接続
 $ tmux attach

                                 7

Mais conteúdo relacionado

Mais procurados

実用裏方 Perl 入門
実用裏方 Perl 入門実用裏方 Perl 入門
実用裏方 Perl 入門keroyonn
 
omoon.org の裏側 〜FuelPHP の task 活用例〜
omoon.org の裏側 〜FuelPHP の task 活用例〜omoon.org の裏側 〜FuelPHP の task 活用例〜
omoon.org の裏側 〜FuelPHP の task 活用例〜Sotaro Omura
 
OPcache の最適化器の今
OPcache の最適化器の今OPcache の最適化器の今
OPcache の最適化器の今y-uti
 
CMSとPerlで遊ぼう
CMSとPerlで遊ぼうCMSとPerlで遊ぼう
CMSとPerlで遊ぼうDaiki Ichinose
 
シェル入門
シェル入門シェル入門
シェル入門ina job
 
CPANの依存モジュールをもう少し正しく検出したい
CPANの依存モジュールをもう少し正しく検出したいCPANの依存モジュールをもう少し正しく検出したい
CPANの依存モジュールをもう少し正しく検出したいcharsbar
 
How to debug a perl script using gdb
How to debug a perl script using gdbHow to debug a perl script using gdb
How to debug a perl script using gdbakirahiguchi
 

Mais procurados (10)

実用裏方 Perl 入門
実用裏方 Perl 入門実用裏方 Perl 入門
実用裏方 Perl 入門
 
VerilatorとSystemC
VerilatorとSystemCVerilatorとSystemC
VerilatorとSystemC
 
omoon.org の裏側 〜FuelPHP の task 活用例〜
omoon.org の裏側 〜FuelPHP の task 活用例〜omoon.org の裏側 〜FuelPHP の task 活用例〜
omoon.org の裏側 〜FuelPHP の task 活用例〜
 
OPcache の最適化器の今
OPcache の最適化器の今OPcache の最適化器の今
OPcache の最適化器の今
 
CMSとPerlで遊ぼう
CMSとPerlで遊ぼうCMSとPerlで遊ぼう
CMSとPerlで遊ぼう
 
Subprocess no susume
Subprocess no susumeSubprocess no susume
Subprocess no susume
 
0x300
0x3000x300
0x300
 
シェル入門
シェル入門シェル入門
シェル入門
 
CPANの依存モジュールをもう少し正しく検出したい
CPANの依存モジュールをもう少し正しく検出したいCPANの依存モジュールをもう少し正しく検出したい
CPANの依存モジュールをもう少し正しく検出したい
 
How to debug a perl script using gdb
How to debug a perl script using gdbHow to debug a perl script using gdb
How to debug a perl script using gdb
 

Semelhante a コマンド実行結果のログ取得について

Debug Hacks at Security and Programming camp 2011
Debug Hacks at Security and Programming camp 2011 Debug Hacks at Security and Programming camp 2011
Debug Hacks at Security and Programming camp 2011 Hiro Yoshioka
 
Programming camp 2010 debug hacks
Programming camp 2010 debug hacksProgramming camp 2010 debug hacks
Programming camp 2010 debug hacksHiro Yoshioka
 
Unix 基礎
Unix 基礎Unix 基礎
Unix 基礎Sho A
 
IT Pro のための PowerShell スクリプティング
IT Pro のための PowerShell スクリプティングIT Pro のための PowerShell スクリプティング
IT Pro のための PowerShell スクリプティングKazuki Takai
 
あんなテスト、こんなテスト(this and that about testing)
あんなテスト、こんなテスト(this and that about testing)あんなテスト、こんなテスト(this and that about testing)
あんなテスト、こんなテスト(this and that about testing)Takuya Tsuchida
 
Building production server on docker
Building production server on dockerBuilding production server on docker
Building production server on dockerHiroshi Miura
 
Building production server on docker
Building production server on dockerBuilding production server on docker
Building production server on dockerHiroshi Miura
 
【学習メモ#1st】12ステップで作る組込みOS自作入門
【学習メモ#1st】12ステップで作る組込みOS自作入門【学習メモ#1st】12ステップで作る組込みOS自作入門
【学習メモ#1st】12ステップで作る組込みOS自作入門sandai
 
モダンmod_perl入門 #yapcasia
モダンmod_perl入門 #yapcasiaモダンmod_perl入門 #yapcasia
モダンmod_perl入門 #yapcasia鉄次 尾形
 
GNU awk (gawk) を用いた Apache ログ解析方法
GNU awk (gawk) を用いた Apache ログ解析方法GNU awk (gawk) を用いた Apache ログ解析方法
GNU awk (gawk) を用いた Apache ログ解析方法博文 斉藤
 
Windows PowerShell 2.0 の基礎知識
Windows PowerShell 2.0 の基礎知識Windows PowerShell 2.0 の基礎知識
Windows PowerShell 2.0 の基礎知識shigeya
 
ホームディレクトリに埋もれた便利なコードをさがせ!
ホームディレクトリに埋もれた便利なコードをさがせ!ホームディレクトリに埋もれた便利なコードをさがせ!
ホームディレクトリに埋もれた便利なコードをさがせ!Yohei Fushii
 
A_road_to_AMBER_simulations_ver_1.0
A_road_to_AMBER_simulations_ver_1.0A_road_to_AMBER_simulations_ver_1.0
A_road_to_AMBER_simulations_ver_1.0Satoshi Kume
 
EC-CUBE + PHPUnit で 実践テスト駆動開発
EC-CUBE + PHPUnit で 実践テスト駆動開発EC-CUBE + PHPUnit で 実践テスト駆動開発
EC-CUBE + PHPUnit で 実践テスト駆動開発Kentaro Ohkouchi
 
Programming camp Codereading
Programming camp CodereadingProgramming camp Codereading
Programming camp CodereadingHiro Yoshioka
 
恋に落ちるデプロイツール
恋に落ちるデプロイツール恋に落ちるデプロイツール
恋に落ちるデプロイツールtotty jp
 

Semelhante a コマンド実行結果のログ取得について (20)

Ilstudy001_20110806
Ilstudy001_20110806Ilstudy001_20110806
Ilstudy001_20110806
 
Debug Hacks at Security and Programming camp 2011
Debug Hacks at Security and Programming camp 2011 Debug Hacks at Security and Programming camp 2011
Debug Hacks at Security and Programming camp 2011
 
Programming camp 2010 debug hacks
Programming camp 2010 debug hacksProgramming camp 2010 debug hacks
Programming camp 2010 debug hacks
 
Unix 基礎
Unix 基礎Unix 基礎
Unix 基礎
 
IT Pro のための PowerShell スクリプティング
IT Pro のための PowerShell スクリプティングIT Pro のための PowerShell スクリプティング
IT Pro のための PowerShell スクリプティング
 
あんなテスト、こんなテスト(this and that about testing)
あんなテスト、こんなテスト(this and that about testing)あんなテスト、こんなテスト(this and that about testing)
あんなテスト、こんなテスト(this and that about testing)
 
Capistrano
CapistranoCapistrano
Capistrano
 
Building production server on docker
Building production server on dockerBuilding production server on docker
Building production server on docker
 
Building production server on docker
Building production server on dockerBuilding production server on docker
Building production server on docker
 
MoteMote Compiler Plugin
MoteMote Compiler PluginMoteMote Compiler Plugin
MoteMote Compiler Plugin
 
【学習メモ#1st】12ステップで作る組込みOS自作入門
【学習メモ#1st】12ステップで作る組込みOS自作入門【学習メモ#1st】12ステップで作る組込みOS自作入門
【学習メモ#1st】12ステップで作る組込みOS自作入門
 
モダンmod_perl入門 #yapcasia
モダンmod_perl入門 #yapcasiaモダンmod_perl入門 #yapcasia
モダンmod_perl入門 #yapcasia
 
GNU awk (gawk) を用いた Apache ログ解析方法
GNU awk (gawk) を用いた Apache ログ解析方法GNU awk (gawk) を用いた Apache ログ解析方法
GNU awk (gawk) を用いた Apache ログ解析方法
 
Windows PowerShell 2.0 の基礎知識
Windows PowerShell 2.0 の基礎知識Windows PowerShell 2.0 の基礎知識
Windows PowerShell 2.0 の基礎知識
 
ホームディレクトリに埋もれた便利なコードをさがせ!
ホームディレクトリに埋もれた便利なコードをさがせ!ホームディレクトリに埋もれた便利なコードをさがせ!
ホームディレクトリに埋もれた便利なコードをさがせ!
 
A_road_to_AMBER_simulations_ver_1.0
A_road_to_AMBER_simulations_ver_1.0A_road_to_AMBER_simulations_ver_1.0
A_road_to_AMBER_simulations_ver_1.0
 
EC-CUBE + PHPUnit で 実践テスト駆動開発
EC-CUBE + PHPUnit で 実践テスト駆動開発EC-CUBE + PHPUnit で 実践テスト駆動開発
EC-CUBE + PHPUnit で 実践テスト駆動開発
 
Programming camp Codereading
Programming camp CodereadingProgramming camp Codereading
Programming camp Codereading
 
恋に落ちるデプロイツール
恋に落ちるデプロイツール恋に落ちるデプロイツール
恋に落ちるデプロイツール
 
about DakotagUI
about DakotagUIabout DakotagUI
about DakotagUI
 

コマンド実行結果のログ取得について

  • 2. リダイレクト (sh / bashの場合) • a.out > text.log – 標準出力のみリダイレクト – 標準エラー出力はリダイレクトされない • a.out > text.log 2>&1 – 標準出力、標準エラー出力ともリダイレクト – 「> text.log」「2>&1」を逆にしてはいけない • a.out 2>&1 | b.sh – 標準出力、標準エラー出力とも、パイプにリダイ レクト 2
  • 3. script $ script Script started, file is typescript $ pwd /home/kawaguchi 新しいシェル $ exit Script done, file is typescript $ cat typescript Script started on Tue Feb 5 18:41:57 2013 $ pwd /home/kawaguchi ログの内容 $ exit Script done on Tue Feb 5 18:41:58 2013 $ 3
  • 5. vi / emacs 【vi】 • :r! a.out – 実行結果をカーソル位置に読み取る • :%! a.out – 指定した範囲を外部コマンドに渡して、実行結果で置き換える 【emacs】 • M-! a.out (M-& a.out) – 実行結果を新しいバッファ(*Shell Command Output*)に表示 • M-| a.out – 選択範囲を外部コマンドに渡す • C-u M-! a.out – 実行結果をカレントバッファに読み込む 5
  • 6. screen • GNUによって開発された、フリーな端末多重接続ソ フトウェア • コマンドライン版のウィンドウシステムのようなもの • ターミナル上で仮想端末を作成する $ screen • スクロールバッファの参照とコピー&ペースト(C-A [、 SPACE~ENTER、]) • 領域を分割(C-A S、TAB、Q) • 複数スクリーンの切り替え(C-A C-C、数字、") • セッションのデタッチ(C-A d)と再接続 $ screen -r 6
  • 7. tmux • 「screen」と同様のソフトウェア(BSDライセンス) • 「terminal multiplexer」の略 • ターミナル上で仮想端末を作成する $ tmux • スクロールバッファの参照とコピー&ペースト(C-B [、 C-@~C-w、C-B ]) • 領域を分割(C-B "、o、!) • 複数スクリーンの切り替え(C-B c、数字、w) • セッションのデタッチ(C-B d)と再接続 $ tmux attach 7