Results 1 to 3 of 3

Thread: Simple question about command syntax ping/log ping results

  1. #1

    Simple question about command syntax ping/log ping results

    Hi all

    I am new to linux and need help on a two simple issues. I'll really appreciate if you can help me.

    Issue 1. On the command line window of red hat 8.0, I want to ping an IP address continuosly and log the ping results as text file. If it is possible, I want to execute both commands(ping and log) in the same line. What would be the correct command syntax? (I mean I need to execute both ping and log with one "ENTER")

    PS: I have to see the ping reply packets on the screen while it is being logged at the same time.

    Issue 2. I need to ping 20 IP addresses on 20 command line windows at the same time, log the ping results as well. In other words I need to do Issue one on 20 windows and 20 IP addresses. Could you help me how to create a script about do Issue 2 with one command?

    command line window 1: pings and logs,
    command line window 2: pings and logs,
    command line window 10: pings and logs

    Thank in advance for helping

  2. #2
    redhead's Avatar
    Join Date
    Jun 2001
    Copenhagen, Denmark
    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:
    # This is a help script, which will start ping and send output to a logfile
    # it is called by: <host> <log file>
    ping $1 | tee $2
    # this is the actual script to execute the 20 pings
    # it uses the 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 <host 1> <log file 1>
    screen -d -m -S screen-2 <host 2> <log file 2>
    screen -d -m -S screen-3 <host 3> <log file 3>
    screen -d -m -S screen-20 <host 20> <log file 20>
    In order to check your progress on this, you can reattach the created screen sessions ie:
    > screen -r screen-1
    for session 1, and so forth.

    If you want to actualy open new windows, then with the use of the use of the you could do something like:
    xterm -e <host 1> <log file 1>&
    xterm -e <host 2> <log file 2>&
    xterm -e <host 3> <log file 3>&
    xterm -e <host 20> <log file 20>&
    Or simply just:
    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>' &
    Last edited by redhead; 07-25-2006 at 01:23 PM.
    Don't worry Ma'am. We're university students, - We know what We're doing.
    'Ruiat coelum, fiat voluntas tua.'
    Datalogi - en livsstil; Intet liv, ingen stil.

  3. #3

    Thanks a lot redhead

    it was extremely helpful post for me thanks again

Similar Threads

  1. Client Machine Ping command not wrking
    By prabahar in forum Linux - Hardware, Networking & Security
    Replies: 1
    Last Post: 01-17-2013, 12:28 PM
  2. Cannot ping other servers
    By hjazz6 in forum Linux - Hardware, Networking & Security
    Replies: 0
    Last Post: 01-12-2009, 08:27 AM
  3. Cannot Ping outside
    By bala in forum Suse
    Replies: 3
    Last Post: 05-09-2007, 06:20 AM
  4. cant even ping localhost
    By sivaram_swdw in forum Linux - Hardware, Networking & Security
    Replies: 2
    Last Post: 05-30-2005, 12:10 AM
  5. Ping
    By mugs in forum Linux - General Topics
    Replies: 5
    Last Post: 01-10-2003, 10:47 AM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts