Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^5: Expect receives no output, when requested via HTML

by Corion (Patriarch)
on Nov 24, 2020 at 14:55 UTC ( [id://11124147]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Expect receives no output, when requested via HTML
in thread Expect receives no output, when requested via HTML

I think you can still remove Expect from the equation if you can manage a passwordless setup, by providing all the input to SSH via STDIN:

use File::Temp 'tempfile'; my ($fh, $output) = tempfile(); close($fh); open my $remote, "| ssh $user\@$hostname >$tempfile" or die "Couldn't launch ssh ssh $user\@$hostname: $!"; print $remote "some test command\n"; print $remote "another test command\n"; print $remote "quit\n"; open my $fh, '<', $tempfile or die "Couldn't read the tempfile?!"; while(<$fh>) { print "Remote: $_"; };

But if you need to provide the password to SSH, there is no way to do that without Expect. All of this hinges on the idea of using (passwordless) ssh keys.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11124147]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-26 04:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found