develooper Front page | perl.perl6.users | Postings from August 2019

Executing remote command via ssh

Thread Next
Mario Galindez
August 24, 2019 18:16
Executing remote command via ssh
Message ID:

I need to execute a program in a remote machine, that takes its input from

I created a user in such remote machine, and set my program as the shell
for that account (so I don't need to provide shell access).

On my local node, I have this program:


    use IPC::Open3;
    use POSIX;

    $inputfile= $ARGV[0];
    open(FILE, '<', "$ARGV[0]") or die $!;
    $command= "ssh user\";
    $pid = open3('<&FILE', '>&STDOUT', '>&STDERR', $command);

    waitpid( $pid, 0 );

What I expect is that I pass the name of the file as arguments of this
program ($ARGV[0]), and the contents of this file is fed as STDIN of the
child I've spawn with open3. This should be received as STDIN of my remote
program, and the results of the remote program would be printed on STDOUT.

This works well. However, my program only reads the first line, and then

If I do a manual test, and do ssh, and type multiple
lines of input, then things work as expected.

Any clues?



Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About