I'm a bit new to perl and am having a bit of trouble getting a sudo (or su for that matter) to work through Net::SSH::Perl.<br><br>Interactive
with a shell doesn't seem to do anything for me. And I'd like to not
have to fuss with the sudoers to turn off the requiretty.
<br><br><br>Snippets of my code utilizing it...<br><br>#!/usr/bin/perl -w<br>#---------------Includes------<div id="mb_0">----------<br>use strict;<br>use warnings;<br>#use Getopt::Std;<br>use Net::SSH::Perl;<br>use Term::ReadKey;
<br>use Getopt::Long;
<br><br>....<br><br>my $cmd = "sudo test";<br>my $ssh =
Net::SSH::Perl->new($hos, interactive =>1, use_pty => 1, debug
=> 1, port => $port, protocol => '2,1', options =>
["BatchMode yes"]) or die("Could not connect");
<br><br>#$ssh->login($user, $pass);<br>$ssh->login($user);<br>#$ssh->shell;<br>my ($stdout, $stderr, $exit) = $ssh->cmd($cmd);<br>print "OUT:$stdout \nERR:$stderr \nEXIT:$exit \n";<br><br>....<br>Response from a sudo test
<br><br>Use of uninitialized value in concatenation (.) or string at ./SerialPush.pl line 79.<br>OUT: <br>ERR:sudo: sorry, you must have a tty to run sudo<br> <br>EXIT:1 <br><br>...<br>Response from a su root test<br><br>
Use of uninitialized value in concatenation (.) or string at ./SerialPush.pl line 79.<br>OUT: <br>ERR:standard in must be a tty<br> <br>EXIT:1 <br><br><br>Any ideas on how I can get this to work?<br>What
I'm trying to do is get a perl script to move a file from tmp to etc,
or just simply write a config file to /etc on a ton of remote systems.
</div>