Link to home
Start Free TrialLog in
Avatar of port_blair2001
port_blair2001

asked on

UNIX Shell Script to Transfer Files via FTP

When i execute the script I get up to here as shown below
Connected to xxxx.com.
220 xxx  FTP server (Version 1.1.214.4(PHNE_34544) Fri Feb 24 15:0
3:24 GMT 2006) ready.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

Its not automatically logging in and puttin the files to the remote server
LOCALDIR=/backup
REMOTESERVER=servername
REMOTEPATH=/backup
LOGIN=xxxx
PASSWORD=xxxx
 
cd $LOCALDIR
ftp -n $REMOTESERVER << INPUT_END
quote user $LOGIN
quote pass $PASSWORD
cd $REMOTEPATH
prompt off
mput * devid.*
exit

Open in new window

Avatar of fseto
fseto

Why not use expect or curl?  http://expect.nist.gov/  http://curl.haxx.se/docs/manpage.html
Doing it your way is rather error prone
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

One more comment, it is not a good practice to put passwords in scripts. Please avoid whenever possible.

If you want a more secure way to transfer files, then consider using sftp / scp (you need ssh installed on the other server and sftp / scp on your side).
Consider using the LFTP client. It is very easy to script it.

http://en.wikipedia.org/wiki/Lftp
I'd suggest ncftp client which contains ncftpget/ncftpput which act in similar manner to rcp/scp, password stored no questions or interaction asked.
use PureFTP, this doesn't require any script

SA
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial