actually i use a perl script the remotely execute the shell script i mentioned above.
here's the content of the perl script, config_net.pl :
#!/usr/bin/perl
$| = 1;
use Net::SSH::Perl;
use Net::SCP::Expect;
die "Usage: $0 LAST_OCTECT\n" if (!$ARGV[0]);
$oldip = '192.168.1.127';
print "Running /bin/setip $ARGV[0]\n";
while ($error = Rpc($oldip, "/bin/setip $ARGV[0]")) {
print "UML not up yet. $error\n";
sleep 2;
}
###############################################################################
sub Rpc {
my ($host,$cmd) = @_;
my $ssh;
print "Starting SSH\n";
eval { $ssh = Net::SSH::Perl->new($host, ['debug' => 'yes',]); };
if ($@) {
return "Failed to connect\n$@";
}
print "Logging into $host\n";
$ssh->login('root', 'root');
my ($stdout, $stderr, $exit) = $ssh->cmd($cmd);
print "Output: $stdout\n";
print "Error: $stderr\n";
return $exit;
}
is the problem lying in this one, or in the shell script??
Jimmy
|