Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: File created but blank

by pc88mxer (Vicar)
on Jul 24, 2008 at 03:23 UTC ( #699760=note: print w/ replies, xml ) Need Help??


in reply to File created but blank

If you checked the return status of your open(PL, ...) call, I bet you would find out that it failed. Since there is no pipe symbol at the end of the file name, you are actually asking perl to read a file with a lot of shell metacharacters in it.

An easier way is just to use system() to directly invoke the command:

system("grep 'packet loss' ... > /home/.../$TARGET_HOST.PL.log");
If you wanted to open a pipe from the command, you would need to terminate it with a pipe symbol, e.g.
open(PL, "grep ... | ... |") or die "unable to open pipe from grep command: $!"; while (<PL>) { ... } close(PL);


Comment on Re: File created but blank
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (20)
As of 2015-07-31 15:02 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 (278 votes), past polls