Sponsored Content
Top Forums Shell Programming and Scripting Copy a file from local host to a list of remote hosts --- perl script Post 302801395 by hanson44 on Thursday 2nd of May 2013 01:14:29 AM
Old 05-02-2013
The basic idea is to put in a shell script:
Code:
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.
 

10 More Discussions You Might Find Interesting

1. Solaris

How to delete the files from local host to remote host

Hi all, i am copying .gz files from production server to development server using "scp" command.my requirement is after copying .gz files i want to delete old .gz files(two days back) in development server from production server. like this way i need to delelte .log ,.z and .dmp files... (3 Replies)
Discussion started by: krishna176
3 Replies

2. UNIX for Advanced & Expert Users

Commands to copy a tar.gz file from a Remote Unix Server to Local Desktop.

Hi, Just wanted to know, how can I ftp/transfer/copy a (design.tar.gz) archive from a Unix Server (sdmc222.sdmc.cp-srv.com) which is at a remote location, to my Windows Desktop. Obviously, it is not possible at cmd prompt on my Windows using the following commands :- ftp... (3 Replies)
Discussion started by: marconi
3 Replies

3. UNIX for Dummies Questions & Answers

Copy files between remote hosts

Don't know if its correct to write into this topic but how can I copy files from a Windows machine to a UNIX system? (2 Replies)
Discussion started by: agasamapetilon
2 Replies

4. UNIX for Advanced & Expert Users

Help! How to find the local host after few ssh hops to remote host???

I do a ssh to remote host(A1) from local host(L1). I then ssh to another remote(A2) from A1. When I do a who -m from A2, I see the "connected from" as "A1". => who -m userid pts/2 2010-03-27 08:47 (A1) I want to identify who is the local host who initiated the connection to... (3 Replies)
Discussion started by: gomes1333
3 Replies

5. Shell Programming and Scripting

ssh to multiple hosts and saving the output in the local host

hi I have a script to login from a host "A" to a list of hosts in a file and perform some commands inside it...its somethin like this for i in `cat file` do ssh -t $i " command1 ; command2; ..." done I wanna save the outputs in a file in the current host "A" i.e from where I am... (3 Replies)
Discussion started by: ningy
3 Replies

6. UNIX for Dummies Questions & Answers

How to copy files from remote server to local?

Hi experts, I 'm newbie to unix world, now I have task to copy the latest files from remote server to my local. I believe this must be very common request in this community. I want you do it one more time for me please. My requirement is something like this: I receive files in the below... (3 Replies)
Discussion started by: parpaa
3 Replies

7. Shell Programming and Scripting

Copy from local to remote

Hi I need a advice for writing simple bash script, I have a file pod.txt which contains source location and remote location: /mnt/infile/20141103/701_0001.png/remote/tmp/pk21730/p0330223723074.png /mnt/infile/20141103/203_0001.png/remote/tmp/pk21731/p0330223723081.png and I must copy ... (6 Replies)
Discussion started by: primo102
6 Replies

8. Solaris

How to copy a tar file on a series of remote hosts and untar it on those hosts?

Am trying to copy a tar file onto a series of remote hosts and untar it at the destination. Need to do this without having to do multiple ssh. Actions to perform within a single ssh session via shell script - copy a file - untar at destination (remote host) OS : Linux RHEL6 (3 Replies)
Discussion started by: sankasu
3 Replies

9. Shell Programming and Scripting

Grep remote multiple hosts output to local server

Hello all, i'm trying to create a report by greping a pattern on multiple remote hosts and creta a simple report, actually i did this, is ther any better way to do this. #!/bin/bash for host in `cat RemoteHosts` do ssh $host -C 'hostname 2>&1; grep ERROR /var/log/WebServer.log.2019-09-21... (0 Replies)
Discussion started by: charli1
0 Replies

10. Shell Programming and Scripting

Copy local files to single remote host but multiple folders using rsync

I'm trying to copy a file myfile.scr from my local Linux server to multiple folders on remote AiX server using single rsync command. Below command helps me copy the file "myfile.scr" from my localhost to a remote host folder "/app/deployment/tmpfiles" rsync --delay-updates -F --compress... (1 Reply)
Discussion started by: mohtashims
1 Replies
GFREP(1)																  GFREP(1)

NAME
gfrep - replicate Gfarm files SYNOPSIS
gfrep [ -mnqvx ] [ -S source-domainname ] [ -D destination-domainname ] [ -h source-hostfile ] [ -H destination-hostfile ] [ -N num-of- replicas ] [ -j num-of-threads ] path ... DESCRIPTION
gfrep creates specified number of replicas of Gfarm files specified by the path to specified set of destination hosts. When set of source hosts are specified, only files stored on the set of source hosts are replicated. A set of hosts can be specified by a domain name and/or a host file. When both a domain name and a host file are specified, a set of hosts is determined by both conditions. If the path parameter is a directory, files under the directory will be copied recursively. OPTIONS
-S source-domainname Specifies the domain name of source filesystem nodes from which replicas will be copied. -D destination-domainname Specifies the domain name of destination filesystem nodes to which replicas will be copied. If neither this nor the -H option is specified, replicas may be copied to any available host. -h source-hostfile Specifies a file which describes hostnames of source filesystem nodes from which the replica will be made. The source-hostfile con- sists of a filesystem node name on each line. if ``-'' is specified, standard input is used to read the host list. -H destination-hostfile Specifies a file which describes hostnames of destination filesystem nodes on which the replica will be made. The destination-host- file consists of a filesystem node name on each line. if ``-'' is specified, standard input is used to read the host list. -N num-of-replicas Specifies the required number of file replicas, counting already existing ones. If there are a sufficient number of replicas in the destination hosts, neither any copying nor any removal will be done. If this option is not specified, -N 1 is assumed. -j num-of-threads Specifies the number of threads to create file replicas simultaneously. This option is only available when compiled by an OpenMP C compiler. By default, it will be the smallest among the number of total files, the number of source hosts, and the number of desti- nation hosts. -m Lets gfrep command do a migrate/move, instead of doing replication. -x Removes file replicas when a set of destination nodes has more file replicas than specified. -n Displays files to be replicated, but does nothing. -q Suppresses non-error messages. -v Displays verbose output. -? Displays a list of command options. BUGS
A source host is not always selected within a set of source hosts. Gfarm 09 November 2009 GFREP(1)
All times are GMT -4. The time now is 04:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy