Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: Re(2): I may be remotely depressed.

by brassmon_k (Sexton)
on Jan 03, 2002 at 00:42 UTC ( #135796=note: print w/ replies, xml ) Need Help??


in reply to Re: Re(2): I may be remotely depressed.
in thread FTP question

I just tested yours...

#!/usr/bin/perl -w open PH, "ps -ef|" or die; close PH;
The result was not to the screen or STDOUT. The command was run like if you used the "system" function. It executed the command but didn't return it's output. I'm not nearly even close as being as good at Perl as you but maybe you got the pipe placement screwed up. (I could be dumb and I'm not understanding what this guy really wants) but my version of it does return the "ps -ef" commands output to the screen on STDOUT. I know my way isn't common but it's a really nice hack and works really good for what I use it for.

Well I'm just offering what I thought the guy wanted. Perl is a lot of fun now that I'm understanding it better.
WOO HOO!


Comment on Re: Re: Re(2): I may be remotely depressed.
Download Code
Re(4): I may be remotely depressed.
by dmmiller2k (Chaplain) on Jan 03, 2002 at 00:59 UTC

    Output doesn't go to the screen because of the terminating pipe character ('|'), instead it goes to the PH file handle, which you must then *read*, using a loop like this:

    #!/usr/bin/perl -w # Note: the 'die' on the next line will probably never trigger open PH, "ps -ef|" or die "$!: opening pipe"; # your snippet was missing this loop: while (<PH>) { print; # or whatever ... } # Note that for pipes, most errors will come when you try to close it, + so # if the command line had a problem, you'd see this 'die' trigger, not # the one on the 'open' close PH or die "$!: opening pipe";

    dmm

    You can give a man a fish and feed him for a day ...
    Or, you can
    teach him to fish and feed him for a lifetime

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2014-09-20 09:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (158 votes), past polls