Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Double Expect Whamy...

by perlknight (Pilgrim)
on Feb 15, 2007 at 03:26 UTC ( #600124=perlquestion: print w/replies, xml ) Need Help??

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

Fellow monks before I head down this path, I would like to know if it is do-able? Could I use Expect to log into a remote host, and sudo as root to run remote command? The environment I am currently at, does not allow you to log in directly as root. Any thoughts? Thanks.

Replies are listed 'Best First'.
Re: Double Expect Whamy...
by Fletch (Bishop) on Feb 15, 2007 at 04:31 UTC

    There's certainly no technical reason it shouldn't work, but keep in mind in order to do that you'd still possibly need to provide a password to sudo on the other side (depending on its configuration). You'd probably want to prompt the local side and send it across, or talk to the sysadmin and get them to allow you to run the one command NOPASSWD: in sudoers.

Re: Double Expect Whamy...
by dsheroh (Monsignor) on Feb 15, 2007 at 15:41 UTC
    Yes, it works fine. I've done it before and it's not overly complicated, although I can't provide code as it's been half a year since my contract with that client expired and I've forgotten most of what I knew about Expect in that time. If you know Expect, it's pretty straightforward. If you don't know Expect, it shouldn't take more than a couple hours (if that) of poking around PerlMonks to get up to speed, and then it's pretty straightforward.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://600124]
Approved by chargrill
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2023-06-07 06:48 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (29 votes). Check out past polls.