in reply to How to remotely execute a command that requires input?

What have you tried so far?

You can do this so many different ways that it would help if you narrowed down your plans. You could use Net::Telnet to use the telnet protocol to log in and run the script, and that would allow you to communicate with the remote server. Or you could use Expect to communicate with the telnet program locally which would then connect to the remote server ...

Or you could connect via rcmd (rsh/rlogin), or ssh. Or you could have a CGI script running on the server that does it for you. Or you could have an entire daemon written in perl for running this - it would run everything local to itself, and receive input from your machine over the network much like a web server.

A bit more detail of your plans would help us help you formulate the rest of your plans.

  • Comment on Re: How to remotely execute a command that requires input?

Replies are listed 'Best First'.
Re^2: How to remotely execute a command that requires input?
by melaniec (Initiate) on Sep 26, 2006 at 14:12 UTC
    Well i'm running the perl script locally on a server, what it is doing is ssh-ing into a 2nd server and running a shell script that requires input. While i've had success i locally opening pipes and feeding input into them, i've yet to successfully do this on a remote machine. system("ssh xxx.xxx.xxx.xxx -l user '..shell script that needs input..'"); thanks!

      How do you do this with local programs? Why do you think that remote programs will be any different? Just remember: ssh is, itself, a local program. Treat it as such, and you may find things are much simpler.

      If you use open("| localprogram") to write to a local program, just use open("|ssh xxx.xxx.xxx.xxx -l user 'shell script that needs input'") to run the local program of 'ssh'.

      (PS: you should respond sooner ... as you notice, most new topics get responses fairly quickly - 12 days is more than enough time for responses. In fact, if you don't have a response within 24 hours, chances of getting any responses goes way down.)