Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Controlling a terminal

by naggiman (Novice)
on Jan 21, 2003 at 12:16 UTC ( #228662=perlquestion: print w/ replies, xml ) Need Help??
naggiman has asked for the wisdom of the Perl Monks concerning the following question:

I want to write a perl script that can send commands into an identified active terminal window (i.e. i can work out the PID and the path to pty) on a Solaris unix server, and have those commands run (only on a terminal owned by the executor of the perl code).

I have searched CPAN and here (and all over the web) and found no clues how it might be done.

Any clues?


Comment on Controlling a terminal
Replies are listed 'Best First'.
Re: Controlling a terminal
by LAI (Hermit) on Jan 21, 2003 at 15:05 UTC

    Hm... I seem to remember being able to do something along the lines of

    # echo "remember, root is watching you" > /dev/ptye4

    (and, incidentally, cat /dev/ptye4), but I think you have to be root either way, and I don't remember it actually executing anything. What you're trying to do is have an external program (tcsh, or whatever your shell is) interpret some commands, and I don't think many shells will like that.

    What is it you're trying to do? Perhaps there's some other way you can accomplish whatever it is.

      You remember right, but this only echo's text to the users terminal rather than run any commands within the terminal for the user.

      Essentially I am trying to write a GUI cluster admin tool, whereby text typed into a console is multiplied out to 2 or more terminal windows (and where each window can be typed in individually) to minimise cluster admin headaches.

      I have the basic perl outline in my head and the GUI side of it written - i just do not currently know how to control a terminal window in this way.

      We have an off-the-shelf tool already but it doesnt support ssh, and it lacks a few "niceties", hence this mini-project.

        So you want to run the same command simultaneously on several cluster nodes. Again, I think it would be too much of a headache to open n terminals and tell them all to pass stuff to shells. You would probably be better off using something like Net::SSH and just maintaining one session per node. Maintain an array of references to connections or something like that, and everytime you type a command into your GUI you iterate across the array and pass the command to each connection.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://228662]
Approved by valdez
Front-paged by tye
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2015-10-14 03:49 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (320 votes), past polls