开发者

ssh command not running perl script

开发者 https://www.devze.com 2023-02-01 07:37 出处:网络
I have following perl script #!/usr/bin/perl $userinput =<STDIN>; chomp ($userinput); while ( $user开发者_StackOverflow中文版input ne \"DONE\")

I have following perl script

#!/usr/bin/perl
$userinput =  <STDIN>;
chomp ($userinput);
while ( $user开发者_StackOverflow中文版input ne "DONE")
{
        print STDOUT "User typed ----->  $userinput\n";
        $userinput =  <STDIN>;
        chomp ($userinput);
}

I have copied this on on unix box, locally this works fine but when I try to run this perl script remotely from another box using ssh, it does not work.

I am running this script using following command.

ssh username@hostname /tmp/testremote.pl

It just hangs on the STDIN and does not return anything.

Any idea why this is not working?


Try adding $|=1; after the #! line.


your terminal's STDIN is probably not being redirected correctly to the remote terminal.

You can try:

ssh username@hostname 'echo bla bla bla | /tmp/testremote.pl'

And if this works it will indicate that the perl script is fine, but the problem is your redirection.


ssh username@hostname '/tmp/testremote.pl'

Please try to add single quote to your command.

0

精彩评论

暂无评论...
验证码 换一张
取 消