djw has asked for the wisdom of the Perl Monks concerning the following question:

Process X is running on a remote box (machine A). I would like to connect to machine A with machine B, and redirect, or retreive a copy of the output of process X to machine B. How is this possible, are there any Perl modules that could help acheive this?

Thanks, djw

Replies are listed 'Best First'.
(jcwren) RE: redirection of output
by jcwren (Prior) on Sep 14, 2000 at 21:47 UTC
    I don't know much about Quake (it makes me ill watching the screen caroming around like that), but rather than all this sockety smickity-smack, take a look at Net::IRC.

    It's very easy to use, and fairly capable. The only issue I've found to date is that it doesn't internally implement any form of flood control, so you may have to use some sort of queueing mechanism. And, flood control is only an issue if you're running through an IRC server, as opposed to a DCC connection.

    --Chris

    e-mail jcwren
RE: redirection of output
by fundflow (Chaplain) on Sep 14, 2000 at 19:39 UTC
    If you use unix, you should probably do this:

    rsh machineA command

    This will return the standard output, just as if you ran it on the local machine.

    If you want also to save the output to a file then do

    rsh machineA 'command | tee filename'

    (it is usually safer to use ssh instead of rsh, although this requires more proccessing on each side for the encryption/decryption)


    Cheers.
Re: redirection of output
by merlyn (Sage) on Sep 14, 2000 at 19:15 UTC
    Well, if you have two different machines, you have to have a wire protocol to get the data across. It doesn't just magically leap from one place to another.

    The simplest would be to run process X as a CGI program, then machine B can simply request that machine A run process X and the output sent in response.

    If that doesn't meet your needs, you'll have to be more specific.

    -- Randal L. Schwartz, Perl hacker

      What I am looking to do is this:

      Machine A = perl program runs a dedicated quake server and pumps output of console to Machine B using a Perlbot in irc
      Machine B = runs a perlbot in irc that can pump out console info and accept and send quake server commands to Machine A.

      Basically a client/server admin tool using IRC.

      Links:
      Perlbot Perlbot Quake3Plugin Similar GUI based (Tcl/Tk) program used for Half-Life servers

      Not the noblest of causes but its a fun project. =)

      Thanks, <a href="http://www.perlmonks.org/index.pl?node_id=16711&lastnode_id=2437"djw
        So, you can still use HTTP, but it's probably overkill unless you want some sort of security.

        Short of that, one solution is to set up a TCP server socket on the quake machine, and have it broadcast whatever's showing up to any and all clients that connect. Then write a simple TCP client on the perlbot side, and when data is ready, feed it to the perlbot.

        -- Randal L. Schwartz, Perl hacker

RE (tilly) 1: redirection of output
by tilly (Archbishop) on Sep 14, 2000 at 19:37 UTC
    I have been happy with ssh for this kind of task. rsh is also possible although it is insecure. No Perl module is needed, just use ssh to run processes remotely.
Re: redirection of output
by Fastolfe (Vicar) on Sep 14, 2000 at 20:37 UTC
    You may want to see about using Net::Telnet to do this as well. This would let you connect and log in to the remote machine remotely. You could then use object methods to execute the command you want, and retrieve data line by line if necessary.

    I personally consider this somewhat of a kludge, but this is probably the solution requiring the least amount of coding on your part. I would go with some of the other recommendations here, involving real TCP client-server interaction, but Net::Telnet should suffice.