First question: take a look at the tee program, in your caseit would be something like:
> ping <your host> | tee log_file.txt
Second question: Theres is no command line way of achieving that.. But you could use the screen program to capture those things..
With a bit of help it should be possible.
Something like:
Code:
#!/bin/sh
# This is a help script, which will start ping and send output to a logfile
# it is called by: script.sh <host> <log file>
ping $1 | tee $2
Code:
#!/bin/sh
# this is the actual script to execute the 20 pings
# it uses the script.sh file in order to fool screen to make seperate logfiles
# for each screen session, else they're all combined into screenlog.0
screen -d -m -S screen-1 script.sh <host 1> <log file 1>
screen -d -m -S screen-2 script.sh <host 2> <log file 2>
screen -d -m -S screen-3 script.sh <host 3> <log file 3>
...
screen -d -m -S screen-20 script.sh <host 20> <log file 20>
In order to check your progress on this, you can reattach the created screen sessions ie:for session 1, and so forth.
If you want to actualy open new windows, then with the use of the use of the script.sh you could do something like:
Code:
#!/bin/sh
xterm -e script.sh <host 1> <log file 1>&
xterm -e script.sh <host 2> <log file 2>&
xterm -e script.sh <host 3> <log file 3>&
...
xterm -e script.sh <host 20> <log file 20>&
Or simply just:
Code:
#!/bin/sh
xterm -e 'ping <host 1> | tee <log file 1>' &
xterm -e 'ping <host 2> | tee <log file 2>' &
xterm -e 'ping <host 3> | tee <log file 3>' &
...
xterm -e 'ping <host 20> | tee <log file 20>' &
Bookmarks