Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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.

Replies are listed 'Best First'.
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";


    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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://135796]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2018-02-21 02:28 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (274 votes). Check out past polls.