Re: Net::Openssh and sudo? SOLVED

2012-01-20 Thread Rajeev Prasad
finally, if anyone needs, here is one which logs on to a remote host as yourself then su to root then run as many commands you wish. saves output in log you can later use. #!/usr/bin/perl   # see http://perlmonks.org/?node_id=890441   use strict; use warnings;   use Net::OpenSSH; use Expec

Re: Net::Openssh and sudo? made some progress: version 3

2012-01-20 Thread Rajeev Prasad
following is working but it keep running the ls -l in loop, i have to ctrl+C it #!/usr/bin/perl   # see http://perlmonks.org/?node_id=890441   use strict; use warnings;   use Net::OpenSSH; use Expect; $Expect::Exp_Internal = 1;   @ARGV == 2 or die $pass1); $ssh->erro

Re: Net::Openssh and sudo?

2012-01-20 Thread Rajeev Prasad
found following which is working to the point where i can get to the root prompt, but not sure why any command after that is not working can anyone give any hint? thank you. CODE: #!/usr/bin/perl   # see http://perlmonks.org/?node_id=890441   use strict; use warnings;   use Net::OpenSSH;

Re: Difference between <> and grep EXPR, <>

2012-01-20 Thread Rob Dixon
On 20/01/2012 13:51, Shawn H Corey wrote: On 12-01-19 11:08 PM, Andrey P wrote: I don't understand why I need to use a list assignment for say scalar(()=<$fh>); but not for say scalar(grep /./,<$fh>); These are not the same. Try this instead: say scalar( grep /^/, <$fh> ); Or even simply

Net::Openssh and sudo?

2012-01-20 Thread Rajeev Prasad
hello, using Net::Openssh how can i use sudo to become some other user (say root) on a target machine and then execute a series of commands as root? i looked and tried to use the expect example given on Net::Openssh page but could not make it to work. my $myssh  = Net::OpenSSH->new($host,   

Re: Difference between <> and grep EXPR, <>

2012-01-20 Thread Shawn H Corey
On 12-01-19 11:08 PM, Andrey P wrote: I don't understand why I need to use a list assignment for say scalar(()=<$fh>); but not for say scalar(grep /./,<$fh>); These are not the same. Try this instead: say scalar( grep /^/, <$fh> ); -- Just my 0.0002 million dollars worth,

Re: Difference between <> and grep EXPR, <>

2012-01-20 Thread Igor Dovgiy
2012/1/20 Andrey P > Hi! > I don't understand why I need to use a list assignment for >say scalar(()=<$fh>); > but not for >say scalar(grep /./, <$fh>); > Because grep gives a list context to its second operand, just like the nuke ( ()= ) operator does. ) Remember, a context is what's