Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to figure out how to use 'sudo su -' with a Net::OpenSSH. I've read the various documentation, but I am still stumped. What I want to do is log onto a box, sudo su - to a particular user, and then dump the crontab contents for that user.
Here is what I have so far -- basically, it sudos alright, but hangs before executing the crontab -l. I have to ctrl-c to get out of the script. When I ssh into the box, and sudo su - to the user manually, it works fine.
Any tips would be much appreciated. Thanks!
use strict; use warnings; use Data::Dumper; use Net::OpenSSH; my $user = 'user'; #this is just for testing -- final script will ask + for user's input. my $password = 'password'; #this is just for testing -- see above my $host = 'whater.host.to.check'; my $ssh = Net::OpenSSH->new($host, user => $user, password => $passwor +d, strict_mode => 0); my $test = $ssh->system('sudo su - user && crontab -l'); #once script + sudos, script hangs until I ctrl-c. print Dumper $test; print Dumper $ssh;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::OpenSSH with sudo su -
by GrandFather (Saint) on Mar 05, 2011 at 20:15 UTC | |
by Anonymous Monk on Mar 05, 2011 at 22:04 UTC | |
|
Re: Net::OpenSSH with sudo su -
by chrestomanci (Priest) on Mar 05, 2011 at 20:21 UTC | |
by Anonymous Monk on Mar 05, 2011 at 20:30 UTC |