0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

コマンドプロンプトのログ出力

Last updated at Posted at 2023-04-26

コマンドをリダイレクトで実行した場合

コマンドプロンプトでコマンドをリダイレクトした場合、結果しかリダイレクトされないのでどんなオプションでコマンドを実行したか分からない。

コマンド
nslookup www.yahoo.co.jp 8.8.8.8 > before.log 2>&1
before.log ※実行したコマンドが表示されない
権限のない回答:

サーバー:  dns.google
Address:  8.8.8.8

名前:    edge12.g.yimg.jp
Address:  183.79.217.124
Aliases:  www.yahoo.co.jp

バッチファイルをリダイレクトで実行した場合

バッチファイルにしてバッチ自身をリダイレクトすればログファイルにコマンドも表示される。

test.bat
nslookup www.yahoo.co.jp 8.8.8.8
nslookup -type=ns yahoo.co.jp 8.8.8.8
コマンド ※バッチファイルをリダイレクトで実行
test.bat > after.log 2>&1
after.log ※ログファイルにコマンドも表示される。
M:\temp>nslookup www.yahoo.co.jp 8.8.8.8 
権限のない回答:

サーバー:  dns.google
Address:  8.8.8.8

名前:    edge12.g.yimg.jp
Address:  183.79.250.123
Aliases:  www.yahoo.co.jp


M:\temp>nslookup -type=ns yahoo.co.jp 8.8.8.8 
権限のない回答:

サーバー:  dns.google
Address:  8.8.8.8

yahoo.co.jp	nameserver = ns01.yahoo.co.jp
yahoo.co.jp	nameserver = ns11.yahoo.co.jp
yahoo.co.jp	nameserver = ns02.yahoo.co.jp
yahoo.co.jp	nameserver = ns12.yahoo.co.jp
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?