in reply to Controlling a terminal

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.


LAI
:eof

Replies are listed 'Best First'.
Re: Controlling a terminal
by naggiman (Novice) on Jan 21, 2003 at 17:20 UTC
    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.


      LAI
      :eof
        After a lot of hunting around on the net I have found out how to do what i want to do; just have to work out whether i not i should be doing it this way in general...
        use warnings; use strict; use constant TIOCSTI => 29719; my $fd; my $c="\n"; open($fd, ">>", "/dev/pts/30") || die "Could not open: $!"; my $val=ioctl($fd, TIOCSTI, $c); print "not ok\n" unless ($val);
        which will send a RETURN into the pseudo terminal (when run as root, anyhow).

        Thanks for your help.

        Or even use something like SOAP or XML/RPC to do the server side work. I do this currently over SSL & apache or with the Frontier::RPC2 to collect some system/app stats with great results. I used to do similar things with ssh + keychain, but sometimes i would get some weird hangs on it.

        An intellectual is someone whose mind watches itself.
        - Albert Camus