Operating System - HP-UX
1834928 Members
2955 Online
110071 Solutions
New Discussion

Re: How to get files from multiple servers in an easy script

 
SOLVED
Go to solution
thijs lankhorst_1
Frequent Advisor

How to get files from multiple servers in an easy script

Hello, i just started to learn a bit about scripting and would like to know what the best way would be to extract multiple files (ftp?) from multiple servers (remsh?) to the local server. The files are CISAM files but need to be flatfiles once extracted. Is there an easy way of doing this using somthing like a loop? Please can you help.
6 REPLIES 6
Steve Steel
Honored Contributor

Re: How to get files from multiple servers in an easy script

Hi


Go to www.shelldorado.com and look at
http://www.shelldorado.com/scripts/cmds/transfer.ftp.txt



That is a good base for you




Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
thijs lankhorst_1
Frequent Advisor

Re: How to get files from multiple servers in an easy script

Thanks Steve,had a look at it and found the website v usefull
Rodney Hills
Honored Contributor
Solution

Re: How to get files from multiple servers in an easy script

If you get a copy of OpenSSH, you could use the "scp" command. Example-

scp remotehost1:/path/file1 /tmp/newfile1
scp remotehost2:/path/file2 /tmp/newfile2

ftp and remsh have potential security problems.

If you have a lot of files on a lot of hosts and you need to run a process on the remote hosts, then you could use "ssh". example-

for h in remotehost1 remotehost2 ; do
for f in /myfile1 /myfile2 ; do
ssh $h "/myconvert $f >/tmp/out; scp -q /tmp/out orighost:/tmp/$h/$f"
done
done

This will loop through a list of remotehosts and files, run a "convert" program on the file, then transfer the converted file back to the original host.

HTH

-- Rod Hills
There be dragons...
Geoff Wild
Honored Contributor

Re: How to get files from multiple servers in an easy script

I do this with rcp as bb userid to grad cfg2html files and store on intranet server:

# cat rcpgetdoc
#!/bin/sh
cd /htdocs/server-files
HOSTS=`cat bbhosts`

for i in $HOSTS; do
SFILE=${i}.html
rcp ${i}:/opt/cfg2html/$SFILE .
chmod 644 $SFILE
done


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Jan Sladky
Trusted Contributor

Re: How to get files from multiple servers in an easy script

Hi, you can also use folowing simple way

/usr/bin/ftp -i -n -v < /ftp_sundance1.txt

cat ftp_sundance1.txt
open 10.32.113.177
user sweet qqqqqq
bin
hash
prompt off
cd $PATH
dir
mget file
bye

open 10.32.113.178
user sweet qqqqqq
bin
hash
prompt off
cd $PATH
dir
mget file
bye

br Jan
GSM, Intelligent Networks, UNIX
thijs lankhorst_1
Frequent Advisor

Re: How to get files from multiple servers in an easy script

Hi

Thanks all for your suggestions and help and have used rcp to do this and worked fine.

Can right the syntax down if anybody is interested.