Re:perl script on remote server linux



Try the code below, wish it works fine for you.

open FILE, "server_list.txt" or die $!;
while(<FILE>) {
print "the host is: $_";
chomp;
system "ssh -x -t $_ \"sudo /home/tadipah/test.sh\" ";
}
close FILE;


--Jeff



Message du 27/08/08 06:33
De : TADIPAH@xxxxxxxxxxxxxx
A : beginners@xxxxxxxx
Copie à :
Objet : perl script on remote server linux

I am trying to execute a perl script from source A to invoke another
script on 5 remote servers. The script is as follows:

#!/usr/bin/perl

open file, "server_list.txt";
@content = ;
$tot=$#content+1;
print "$tot \n";

while ($tot > 0)
{
$m = shift @content;
print "$m \n";
`ssh -x -t $m "sudo /home/tadipah/test.sh"` ;
sleep 5;
exit
}
Server_list above has the list of servers the script needs to be executed
on.
Above script works fine until it connects to the server and asks me the
password. After I type the password, the putty sessions freezes.

When I use the line below alone without the while or foreach loop, it
works absolutely fine and returns me the output of the script test.sh from
remote computer.
`ssh -x -t SERVERNAME "sudo /home/tadipah/test.sh"` ;

Any help is appreciated.

Créez votre adresse électronique prenom.nom@xxxxxxxxxxx
1 Go d'espace de stockage, anti-spam et anti-virus intégrés.


Relevant Pages

  • Re: OT: security
    ... this remote file will be included into ... the script and executed. ... Note that the remote server would have to ... Mechanisms such as the above allow attackers to execute any code they ...
    (comp.lang.php)
  • RE: remote scripting how to
    ... I re-engineered the following script from the example ... if i check taskmanager i can see the exe sitting there on the ... remote server but not doing what its supose to do, ... > will launch a file remotely on a machine, or copy the file to launch on the ...
    (microsoft.public.windows.server.scripting)
  • Re: how to encrypt password stored in ftp script
    ... I need that script to run everyday automatically on machine ... people form modifying script to access the FTP server for different ... Hiding your username and password in this circumstance is impossible ... include this in a form that can be read by the remote server. ...
    (comp.lang.perl.misc)
  • Re: performance efficient "tail"
    ... > I'm trying to write a script which parses the end of a 1GB log which is ... > located on a remote server. ... I don't mind first saving the "tail"ed text ...
    (perl.beginners)
  • Re: Renaming over SCP
    ... Kristian Domke wrote in ... I have to write a script, ... > files onto a remote server via scp and then has to rename them ... > I don't want through the hell of scripting sftp, ...
    (alt.os.linux.suse)