Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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

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

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

What do you mean?

I tested the little Perl snippet on my SPARC and it produces the output on STDOUT for the "ps -ef" command. I don't get what you mean for "standard input". I know the handle is used for INPUT processing via a file Handle but what I suggested still works. It's probably not syntaticallly correct but it works perfect. Perl doesn't seem to care if the pipe (|) is in front. It does send the "ps -ef" command to STDOUT though I guarantee it...try it. I also found it convienient to give it a handle because then this guy can manipulate the data any way he wants to later on. I might be misunderstanding you though.

The Brassmon_k
  • Comment on Re: Re(2): I may be remotely depressed.

Replies are listed 'Best First'.
Re: Re: Re(2): I may be remotely depressed.
by brassmon_k (Sexton) on Jan 03, 2002 at 00:42 UTC
    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!

      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://135793]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2018-02-19 02:25 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (257 votes). Check out past polls.