Shell Script Help
Hi Guys,
Can someone help me on ftping files via shell script please ? i have created a script but its getting st-rucked after connecting to the ftp location (i can see that logs). Please see below i have pasted script and log. #SCRIPT# .env set -a ################## #Local Variables ################## LOGDIR=/logs LOGFILE=ftp.log PICKUPDIR=/alpha/beta/ DROPDIR=/home/shiva/ DATE=`date +%Y-%m-%d` GATEWAY=12.25.30.25 USERID=shivaprasath PASSWD=cmm1234 ########### #FUNCTIONS# ########### #function to pull Files ftp_copy () { ftp -in $GATEWAY user ${USERID} ${PASSWD} cd ${PICKUPDIR} lcd ${DROPDIR} mget MP3_${DATE}* bye ! } >> $LOGDIR/$LOGFILE ############# #Main Script# ############# echo "Starting Files ftp: \c" >> $LOGDIR/$LOGFILE date >> $LOGDIR/$LOGFILE ftp_copy echo "Ending Files ftp: \c" >> $LOGDIR/$LOGFILE wait date >> $LOGDIR/$LOGFILE exit 0 #End of Script# # ftp.log# Starting Files ftp: Wednesday, 4 April 2012 16:21:43 BST Connected to 12.25.30.25. Welcome to the FTP Site Remote system type is Windows_NT. ftp> ftp> Regards, Shiva |
When you need to "discuss" through network with shell, you have to use netcat. But, just for ftp transfers, I think you could use "ftpput" and "ftpget"
|
Hi,
probably your FTP function is not getting what it's supposed to: Code:
#!/bin/sh Just for an option, if you could use LFTP instead of Ftp, that would solve you much trouble with FTP scripting. good luck |
please use [code][/code] tags around your code and data, to preserve formatting and to improve readability. Please do not use quote tags, colors, or other fancy formatting.
QUOTE ALL OF YOUR VARIABLE SUBSTITUTIONS. You should never leave the quotes off a parameter expansion unless you explicitly want the resulting string to be word-split by the shell (globbing patterns are also expanded). This is a vitally important concept in scripting, so train yourself to do it correctly now. You can learn about the exceptions later. http://mywiki.wooledge.org/Arguments http://mywiki.wooledge.org/WordSplitting http://mywiki.wooledge.org/Quotes Environment variables are generally all upper-case. So while not absolutely necessary, it's good practice to keep your own user variables in lower-case or mixed-case, to help differentiate them. $(..) is highly recommended over `..` |
All times are GMT -5. The time now is 01:28 AM. |