How can I pipe "Y" into netstat.exe to satisfy N/Y demand
Posted: 23 May 2010 15:51
This code causes netstat (standard Windows executable) to record outgoing network activity.
When Ctrl'C is entered then activity.txt is closed ready for viewing.
I want netstat to instantly close down - I do not want it running anymore
Unfortunately it will not go away without being given either Y or N
When I close with Ctrl'C the response is
^CTerminate batch job (Y/N)?
to which I tried ugh, and then Z, then A then the valid N
After which netstat decided to close down and allow my script to say it was ending.
This is what the screen looked like
I would like to give Netstat a valid Y or N by piping that character from the script,
so the ONLY keyboard action needed is the Ctrl'C
The DOS command TIME will show the current time
and then offer the opportunity to change the time
and it requires a keyboard entry before it goes away.
This is a clever trick that simulates keyboard entry :-
ECHO. | MORE | TIME
I was hoping for a similar trick with Netstat.
Help
Regards
Alan
When Ctrl'C is entered then activity.txt is closed ready for viewing.
I want netstat to instantly close down - I do not want it running anymore
Unfortunately it will not go away without being given either Y or N
Code: Select all
ECHO XLOWTEST IS RUNNING
netstat -b 5 > activity.txt
ECHO XLOWTEST IS ENDING
PAUSE
When I close with Ctrl'C the response is
^CTerminate batch job (Y/N)?
to which I tried ugh, and then Z, then A then the valid N
After which netstat decided to close down and allow my script to say it was ending.
This is what the screen looked like
Code: Select all
C:\Utils\Sys_Test>ECHO XLOWTEST IS RUNNING
XLOWTEST IS RUNNING
C:\Utils\Sys_Test>netstat -b 5 1>activity.txt
^CTerminate batch job (Y/N)? ugh
Terminate batch job (Y/N)? Z
Terminate batch job (Y/N)? A
Terminate batch job (Y/N)? N
C:\Utils\Sys_Test>ECHO XLOWTEST IS ENDING
XLOWTEST IS ENDING
C:\Utils\Sys_Test>PAUSE
Press any key to continue . . .
I would like to give Netstat a valid Y or N by piping that character from the script,
so the ONLY keyboard action needed is the Ctrl'C
The DOS command TIME will show the current time
and then offer the opportunity to change the time
and it requires a keyboard entry before it goes away.
This is a clever trick that simulates keyboard entry :-
ECHO. | MORE | TIME
I was hoping for a similar trick with Netstat.
Help
Regards
Alan