Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch file for copying a file.

Status
Not open for further replies.

joeythelips

IS-IT--Management
Aug 1, 2001
305
IE
Hi,

I need to copy a file from our Unix file system to a local pc every day.

A non technical person needs the file so i want there to be as little hassle for her as possible.

What would be the best way to do this?

Joe
 
Set up a script to ftp to the IP address of the PC
and call the script from cron
HTH ;-) Dickie Bird
db@dickiebird.freeserve.co.uk
 
#!/bin/ksh
DIR = directory on PC for files to reside
TRANSFILE= your file to send
#Set up command to login
RHOST= valid PC IP ADDRESS
RUSER=valid login to folder on PC
RPASS= '' password '' '' ''
echo "machine ${RHOST}
login ${RUSER}
password ${RPASS}
" > ${HOME}/.netrc
chmod 600 ${HOME}/.netrc

echo "cd ${DIR}" > tmpfile
echo "put ${TRANSFILE} " >> tmpfile
echo "bye" >> tmpfile
cat tmpfile | ftp -i -v ${RHOST} > tmp.out 2>&1

Give this script a name eg (yourscript). make it executable and call from cron

eg
crontab -e
insert a line like
00 12 * * 1-5 /scripts/yourscript

This'll run each working day at 12 noon
Works for Aix 4.3.3
HTH ;-) Dickie Bird
db@dickiebird.freeserve.co.uk
 
The above mentioned process does require some sort of ftp server be running on the P/C side. ;-)
-Danny
dan@snoboarder.net






 
If there is not a FTP server running on the PC, then another way would be to use the PC to FTP to the server and get the file. This can be automated also, and then you could use a scheduler on the PC to get the file.

Make a script as follows:

open ipaddress
loginname
password
binary (if not a text file)
get filename
quit

Call the script something descriptive (like getfile.scr)
Use the following command to run the script ftp -s:getfile.scr

You could even setup a batch file to put the file in a specific location

cd /directoryname
ftp -s:getfile.scr


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top