Results 1 to 8 of 8

Thread: Command confusion.....

  1. #1
    Join Date
    Nov 2006
    Location
    Gloucester, ENGLAND
    Beans
    201

    Command confusion.....

    Hi guys,

    Quick question. The following line works...
    Code:
    ping 192.168.0.101 > /home/phillips321/failtime.txt
    But this one doesn't, any ideas?
    Code:
    ping 192.168.0.101 | grep 192.168.0.101 > /home/phillips321/failtime.txt
    Cheers in advance
    Have a go at hacking with a Gnome version of BackTrack called GnackTrack.co.uk

  2. #2
    Join Date
    Nov 2005
    Location
    NEK Vermont
    Beans
    Hidden!
    Distro
    Ubuntu UNR

    Re: Command confusion.....

    Quote Originally Posted by phillips321 View Post
    Hi guys,

    Quick question. The following line works...
    Code:
    ping 192.168.0.101 > /home/phillips321/failtime.txt
    But this one doesn't, any ideas?
    Code:
    ping 192.168.0.101 | grep 192.168.0.101 > /home/phillips321/failtime.txt
    Cheers in advance
    Command can't be piped until it has completed is my guess. Try:
    Code:
    ping -c 5 192.168.0.101 | grep 192.168.0.101 > /home/phillips321/failtime.txt

  3. #3
    Join Date
    Apr 2008
    Location
    Germany - Berlin
    Beans
    340

    Re: Command confusion.....

    It would be interesting to know what you want to do. Do you want to see when the ping succeeds or when the ping times out? Or is it just a general question with ping as an example?

  4. #4
    Join Date
    Oct 2007
    Beans
    10

    Re: Command confusion.....

    Quote Originally Posted by phillips321 View Post
    Hi guys,

    Quick question. The following line works...
    Code:
    ping 192.168.0.101 > /home/phillips321/failtime.txt
    But this one doesn't, any ideas?
    Code:
    ping 192.168.0.101 | grep 192.168.0.101 > /home/phillips321/failtime.txt
    Cheers in advance
    Interesting. I get the same result but if I add a count argument to the ping it works correctly. What seems to happen is that without the count the ping has to be stopped by an ^c. In the first version ping handles the output file o.k. but with the second version the grep does not.

  5. #5
    Join Date
    Nov 2005
    Location
    NEK Vermont
    Beans
    Hidden!
    Distro
    Ubuntu UNR

    Re: Command confusion.....

    The example without count, creates an empty file for me, so grep is successful but there is nothing to pipe because the command has not exited...is what I think is happening.

    Running the command without a pipe or a count, creates a growing file.

  6. #6
    Join Date
    Oct 2007
    Beans
    10

    Re: Command confusion.....

    Quote Originally Posted by spiderbatdad View Post
    The example without count, creates an empty file for me, so grep is successful but there is nothing to pipe because the command has not exited...is what I think is happening.

    Running the command without a pipe or a count, creates a growing file.
    If pipe has to wait till preceeding command terminates it would be pretty useless. The grep command should read and process each line as supplied by standard out from ping. Try the same thing with the ping replaced by any other command outputing lines forever and you will find it works.

    I have also tried the ping|grep in cygwin and it works correctly.

    I would suggest that this is a bug.

  7. #7
    Join Date
    Nov 2006
    Location
    Gloucester, ENGLAND
    Beans
    201

    Re: Command confusion.....

    fingers crossed this is a bug (cause its confused the hell outta me), what command is causing the bug though? where do i report it?

    cheers
    Have a go at hacking with a Gnome version of BackTrack called GnackTrack.co.uk

  8. #8
    Join Date
    Sep 2006
    Beans
    2,914

    Re: Command confusion.....

    Code:
    ping 192.168.0.101 | grep "icmp_seq=3" 2>&1

Bookmarks

Posting Permissions

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