Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save Ping Output to Text File

I am using this batch command to save ping output to a text file,

ping 10.226.2.10 -n 10 >>ping_ip.txt

But when i saved the above command in a batch file and trying to run it, in command prompt window my command gets converted to the below command...

ping 10.226.2.10 -n 10  1>>ping_ip.txt

you can see there is extra 1 in 1>> in the second command, i don't know how it came.. somebody please give your valuable opinion on the same

like image 209
Nishant Kumar Avatar asked Oct 25 '16 06:10

Nishant Kumar


1 Answers

This is just the normal behaviour.

In batch files you have some input/output streams:

  • 0 = standard input stream
  • 1 = standard output stream
  • 2 = standard error stream
  • 3-9 = user defined streams

Your >> operator implicitly redirects the standard output stream, that is, it is redirecting the stream number 1, and the cmd parser converts the command

command >> output

into

command 1>> output

showing the explicit command executed based in an implicit request

like image 103
MC ND Avatar answered Sep 23 '22 03:09

MC ND