RE: Shell script to call FTP [off-topic]

  • From: "Vordos, Suzy" <Suzy.Vordos@xxxxxxxxx>
  • To: "alex@xxxxxxxxxxxxxx" <alex@xxxxxxxxxxxxxx>, Oracle I List <oracle-l@xxxxxxxxxxxxx>
  • Date: Tue, 5 Apr 2011 13:43:57 -0600

If you must use ftp rather than scp -- then look into using the .netrc file 
(man netrc).   The login, passwd and ftp commands can be stored in .netrc as a 
macro, then executed via shell script.   .netrc lives in $HOME of the user 
executing the script and must be 600.

-- .netrc
machine <hostname> login <user> password <passwd>
macdef mymacro
cd <somedirectory>
put $1

-- shell
print "$ mymacro myfile "| ftp -v ${FTP_SYSTEM} > ${FTP_LOGFILE}
if grep "^250 Transfer complete" ${FTP_LOGFILE} >/dev/null 2>&1 ||
   grep "^226 Transfer complete" ${FTP_LOGFILE} >/dev/null 2>&1 ; then
     "success"
    else
      "fail"
fi





________________________________
From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx] On 
Behalf Of Alex List
Sent: Tuesday, April 05, 2011 1:41 PM
To: Oracle I List
Subject: Shell script to call FTP [off-topic]

Hi,

Sorry for posting an off-topic email, but I guess that my simple doubt is 
really simple to you guys.

In my shell script to transfer files, I am having difficult to do the way I 
need.
Basically when I invoke the shell, it supposed to log in on FTP server with 
password authenticated and so execute the ftp commands.

############
ftp ftp://backup:bkp123@xxxxxxxxx << _EOF_ >>/dev/null 2>&1
 bin
 prompt
 cd /srv43
 lcd /db/bugtracker/
 mput *.gz
 quit
_EOF_
############

However, when I try to execute I get error like: unknown host

Do you have a suggestion what I am doing wrong??
This same script needs to run on Linux64/bash and AIX.

Thank you in advance for any clue.
Alex

________________________________
This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and destroy
all copies of the communication and any attachments.

Other related posts: