Copy a file from local host to a list of remote hosts --- perl script

Hi friends,

i need to prepare a script ( in perl)

i have a file called "demo.exe" in my local unix host.

i have a list of remote hosts in a file "hosts.txt"

now i need to push "demo.exe" file to all the hosts in "hosts.txt" file.

for this i need to prepare a script(in perl, but shell script also can be accepted), once i execute the script the "demo.txt" file should be copied to all the remote hosts in "hosts.txt" file.

i request all of you, please help me in this regard..

Thank you

Hi Siva,

Could you please let us know what have you tried till now?

Hi friend,

i am very new to this UNIX environment, i am not getting any idea how can i do this.
could you please help me in this?

If you are really new to Unix, I have two suggestions:

  • Kind of ambitious project to start off with. Copying files to remote hosts is not a "beginner" activity.

  • I would suggest using shell rather than perl, because shell is more fundamental to learning and using Unix.

ok, could you please guide me what are the steps that i have to do to copy a file from my local server to remote server?

so that i can implement in shell script.

The basic idea is to put in a shell script:

while read host; do
  scp demo.exe destination
done < hosts.txt

There are two difficult things here, maybe more.

First, you must specify the destination part, and build in the $host variable read from the hosts.txt file. Destination will be something like hanson44@myhost.com:/home/mydir but will depend on your local situation.

Second, you must have permissions set up to do the copying to the remote host. Again, that can be complicated and will depend on your local situation.

Before doing the shell script, you will need to make the scp work on the command line. Once you get that going, writing the shell script is not that difficult.