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!

FTP Shell Script

Status
Not open for further replies.

vvicin01

Programmer
Aug 14, 2001
21
US
I need help creating a shell script to open a UNIX FTP server to transfer files. Can someone assist me. I will schedule a CRON to run the script which would open a remote server and transfer a directory to the server.

Thanks
Vic
 
There are many ways to do this. Here's one idea to get you started.
Code:
ftp -n servername << !
user loginname password
ls
put localfile remotefile
get remotefile localfile
!

Bear in mind that if you run a script in cron, it won't automatically have access to environment variables which you have defined yourself as a user.

Greg.
 
The 'engine' of your ftp requirement could be:

ftp -n <IP Address> <<!
user <username> <password>
cd <whereever you want to put the files>
put <files>
(Or mput if more than one and they can be identified by wildcarding)
bye
!

Hope this helps. Basically the bit between the <<! and the !, reads the commands through to ftp.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top