I am trying to understand a UNIX script which FTPs certain files from a remote location to the local machine. I understand the basic FTP command but the UNIX script uses the following command:
ftp -n -i -v > $logftp_trg 2>&1 <<!
open $MFX_FTP_SERVER
user $MFX_FTP_LOGIN $MFX_FTP_PWD
Can anyone explain me the step by step working of these commands.
A standard Unix or Linux ftp client supports all the given command line options and the two given commands. Not sure why you claim it is not a traditional ftp client.
To the OP, you have only provided us with a part of the ftp client script. The first line invokes FTP with a number of arguments. Look at an ftp man page for an explanation of the n,i,v arguments. "> $logftp_trg 2>&1" means save STDOUT and STDERR to a file specified by the variable "logftp_trg". "<<!" is the start of a shell here document.
The second line invokes the ftp command "open" with the host to open specified by the variable MFX_FTP_SERVER
The third line invokes the ftp command "user" with the username and password to be send to opened host specified by the variables MFX_FTP_LOGIN and MFX_FTP_PWD respectively.
Where are all these variables are being set? Either in a previous part of the script or they are in your environment.
Thanks Fpmurphy for the explanation. I got what you explained except one part. What is the use of "<<!" in ftp -n -i -v > $logftp_trg 2>&1 <<!
. Also does '$logftp_trg 2>&1' simply inserts the oupt into the file specified by $logftp_trg. If we want to send the STDOUT and STDERR in the file shoudn't it be like '2>&1>$logftp_trg'
In this case, the limit string is ! , and your heredoc is a bunch of commands for FTP. Someplace further down you should have a line that consists only of ! , which terminates the heredoc.