Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: using Backtick inside perl gives different output

by jwkrahn (Monsignor)
on Oct 07, 2013 at 23:33 UTC ( #1057328=note: print w/ replies, xml ) Need Help??


in reply to using Backtick inside perl gives different output

Another way to do it:

#!/usr/bin/perl use strict; use warnings; open my $cmd, '-|', '/usr/sbin/ntpq', '-p' or die "Cannot open pipe fr +om ntpq because: $!"; while ( <$cmd> ) { my $offset = ( split )[ 8 ]; print "$offset\n" if /^\*/; } close $cmd or warn $! ? "Error closing ntpq pipe: $!" : "Exit status $? from ntpq";


Comment on Re: using Backtick inside perl gives different output
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1057328]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2015-07-04 01:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls