Thanks to everybody who gave input.  Not only did I get my problem solved,
but I learned how xargs works and about fping.

thanks again


david

On Sat, 23 Dec 2000, Nitebirdz wrote:

> On Fri, 22 Dec 2000, rpjday wrote:
> 
> > On Fri, 22 Dec 2000, David Brett wrote:
> >
> > > I am trying to pipe to ping without success.
> > >
> > > awk '{print$1} testfiles | ping -nc 1
> > >
> > > testfile is
> > >
> > > 10.1.1.1  server1
> > > 10.1.1.2  server2
> > >
> > > Any ideas why I can't pipe to ping?
> >
> > perhaps because, according to ping, it doesn't accept hostnames
> > on standard input.  also, it doesn't *appear* to accept multiple
> > arguments.
> >
> > check the man page.
> >
> > rday
> >
> 
> Not really.  The first part of his command should take care of that and
> pass only the first field to 'ping'.  The problem is rather with the way
> the pipe works in UNIX and Linux.  In this case, the output of
> 'awk '{print$1}' testfiles' is the standard input (stdin) to 'ping'.  The
> only problem is that 'ping' does not take standard input this way.  You
> should use the 'xargs' command and that should fix the problem, as in:
> 
> awk '{print$1}' testfiles | xargs ping -nc 1
> 
> 
> Basically, 'xargs' takes the standard input passed through the pipe and
> sort of pastes it to the end of the 'ping' command.  Check the manual page
> for a more technical explanation.
> 
> 
> 
> 
> ------------------------------------------------------
> Nitebirdz
> ------------------------------------------------------
> Thus spake the master programmer:
> "You can demonstrate a program for a corporate
> executive, but you can't make him computer literate."
> 
> 
> 
> _______________________________________________
> Redhat-list mailing list
> [EMAIL PROTECTED]
> https://listman.redhat.com/mailman/listinfo/redhat-list
> 



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to