1

I have a Perl script which access a remote machine using openssh and executes a Perl script in that remote machine.

Now the problem is that the script which needs to be executed in remote machine is an interactive script and expects some input during execution through STDIN.

Could some one help me with the implementation of this scenarion.

I am placing the snippet of code which I have implemented till now.

my $ssh = Net::OpenSSH->new("$host", timeout => 60) or die "unable to connect to remote host: ". $ssh->error;
$ssh->system("chmod 755 abc.pl"); 
my $output=$ssh->capture("./abc.pl") or die "remote command failed: "  . $ssh->error;
2
  • 1
    See here: search.cpan.org/~bnegrao/Net-SSH-Expect-1.09/lib/Net/SSH/… Commented Aug 31, 2017 at 11:00
  • capture provides the option stdin_data for that. If the interaction is complex, you may like to use Expect instead. Read the module documentation! Commented Sep 2, 2017 at 11:56

1 Answer 1

1

if you are having the execution done automatically then you will not be able to ask for input from a user. you will have to run the script manually or you will have to modify the script on the remote server to accept variables from the remote execute.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.