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

Dear all, This question is related to client server model. My client is perl script on windows and server is linux based DM816x processor. The .out that executes on server accepts standard input at some of time and gives the satandard output. My task is: 1) To run the .out from the client. 2) Once it starts running sending data to the standard input of the .out running on the server. 3) After data is sent capture the data printed on standard ouput of the server and get it back to client for parsing. I have tried telent module for the same. As far I undestand I am able to send only commnads(able to run .out) but not able to send data to standard input of .out. Please help what to use and how?
  • Comment on Sending and receiving data to standard input and output of the linux based server.

Replies are listed 'Best First'.
Re: Sending and receiving data to standard input and output of the linux based server.
by salva (Canon) on Mar 01, 2013 at 09:52 UTC
    Nowadays, the standard way to run commands in a remote Linux or Unix server is to use SSH. Telnet is an insecure and obsolete protocol.
    use Net::SSH::Any; my $ssh = Net::SSH::Any->new($host, user => $user, password => $passwo +rd); my $output = $ssh->capture({stdin_data => $input_data}, $cmd);
    On Windows, in addition to Net::SSH::Any, you will have to install Net::SSH2, there are ppm versions of this package available from the net.
Re: Sending and receiving data to standard input and output of the linux based server.
by tmharish (Friar) on Mar 01, 2013 at 08:13 UTC
Re: Sending and receiving data to standard input and output of the linux based server.
by Exploringperl (Initiate) on Mar 01, 2013 at 13:05 UTC
    Thnaks for Information!! But the question is slight different. I can do either telnet, ssh or http daemon to connet to server and issue commands. I can even wait for the response. But all these assume that on the server side there is a standard command/shell prompt. My question is once I issue the command (eg ./run.out), this run.out waits for some <STDIN> and the prompt is ">>" instead of "# or $ or ~". The .out is now waiting for some data at the stdin, so I need to send some Data after it waits for STDIN. How to I Send data to the .out running at server waiting for the <STDIN>?

      SSH the file with params and redirect the input?

      ./run.out < file_with_params_SSHed_from_client > output_you_can_ssh_ba +ck_to_client
      I can do either telnet, ssh or http

      Great - so use HTTP. These days web services are pretty trivial and you can use HTTPS for additional security and authentication. Simply send the server some data as query string or POST params and await the response. Let all the tricky interface stuff happen on the server side.