Operating System - HP-UX
1834934 Members
2722 Online
110071 Solutions
New Discussion

FTP Automation (Script) Inquiry

 
SOLVED
Go to solution
fbi
Occasional Contributor

FTP Automation (Script) Inquiry

I would like to automate an FTP function thru scripting. Can someone send me a sample script containing the required commands/info to do this?
4 REPLIES 4
Jim Mallett
Honored Contributor
Solution

Re: FTP Automation (Script) Inquiry

This is a basic script that I have that FTPs from on of my Unix servers. The main problem with this is the hard coding of the passwords.
-v is for verbose
-n is to disable the auto-login.

# File Name : ftpprov.sh
#
ftp -v -n >/home/batchjob/ftpprov.log << EOJ
open 10.10.2.10
user
cd prod
ascii
put /general/todspl.dat provfe

Hope this provides some direction.

Jim
close
bye
EOJ
Hindsight is 20/20
Sundar_7
Honored Contributor

Re: FTP Automation (Script) Inquiry

Jim's script is the way to go except that the signature should come after the script :-).

ftp -v -n >/home/batchjob/ftpprov.log << EOJ
open 10.10.2.10
user
cd prod
ascii
put /general/todspl.dat provfe
close
bye
EOJ
Learn What to do ,How to do and more importantly When to do ?
Jim Mallett
Honored Contributor

Re: FTP Automation (Script) Inquiry

Thanks Sundar.... silly me.

I've been away so long I've forgotten how to cut/paste/reply at the same time.
Hindsight is 20/20
Victor Fridyev
Honored Contributor

Re: FTP Automation (Script) Inquiry

Hi,

You can also use the following:
In the home dir of the user, which runs ftp the file called .netrc should be created. The file's example is below, after "macdef init" you may write all ftp commands:

machine ftp_server_name
login usern
password PASSWD
macdef init
asci
cd incoming
lcd /tmp
put swlist.out
quit

After this the user runs ftp ftp_server_name and that's all

HTH
Entities are not to be multiplied beyond necessity - RTFM