![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how do i generate random integer using only shell script | sridhusha | Shell Programming and Scripting | 1 | 12-31-2007 03:46 AM |
| FTP random files | whegra | Shell Programming and Scripting | 3 | 11-21-2007 05:22 PM |
| replacing a number with random variable inside shell script | user_prady | Shell Programming and Scripting | 3 | 09-11-2007 02:44 AM |
| random function script | prash_b | Shell Programming and Scripting | 4 | 09-15-2006 04:54 AM |
| generate random number in korn shell | frustrated1 | Shell Programming and Scripting | 2 | 12-31-2005 07:49 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
The following script is used to loop through files in the /tmp directory and transfer those files onto another server.
However, some of the files do not transfer. It is very random when the transferring is done (i.e. one of the files won't transfer then next time, that one will transfer and another won't transfer.) Any suggestions as to why? Thanks in advance! #! /bin/sh -x # Print date into log file date #associate parameters to p variables p1=$1 p2=$2 p3=$3 p4=$4 #echo parameters into log file echo "" echo "Input parameters are: param1(Oracle User/Password) = ********" echo " param2(User Acct Num) = $p2" echo " param3(Requestor Name) = $p3" echo " param4(Request ID) = $p4" echo "" #set up Unix script variables LOCAL_DIR=$SRS_TOP/sql TMP_DIR=$APPLTMP LOG_FILE=l$p4.req FTP_SERVER=$5 FTP_LOGON=$6 FTP_PASS=$7 TIMESTAMP=`date '+%m%d%y%H%M%S'` #now do the xfer to the getpaid server echo "" echo "FTP parameters are: SERVER = $FTP_SERVER" echo " LOGIN = $FTP_LOGON" echo " PASS = *********" echo " TEMP = $APPLTMP" echo " REQUEST = $p4" echo "" FTP_OUTFILE=ar*.txt cd $APPLTMP #Verify Host filename(s) and put into Local_Dir list for file in $FTP_OUTFILE do if test -f $file; then TEMP_FILE=/tmp/ftp$p4$file #Verify Host Directory exists if test -d "$TMP_DIR"; then HOST_DIR=$TMP_DIR; else echo "Invalid Host Dir [$TMP_DIR]" exit 1; fi #Set success/failure flag TESTCOND=0 #Create the ftp script echo "open $FTP_SERVER" >> $TEMP_FILE echo "user $FTP_LOGON $FTP_PASS" >> $TEMP_FILE echo "ascii" >> $TEMP_FILE echo "prompt" >> $TEMP_FILE echo "cd getpaid\nlcd $TMP_DIR" >> $TEMP_FILE echo "put $file" >> $TEMP_FILE echo "bye\n" >> $TEMP_FILE #11/21/02 - JEM - Get rid of two temp files used to capture problems rm /tmp/ftp.err /tmp/ftp.failed #Execute the FTP script created #11/21/02 - JEM - Redirect the message output if ftp -n < $TEMP_FILE > /tmp/ftp.err 2>&1; then echo ""; else echo "ftp command failed!\n" exit 1; fi #11/21/02 - JEM - Added next 7 lines because the test above does not really catch errors grep -i 'Connection refused' /tmp/ftp.err > /tmp/ftp.failed grep -i fail /tmp/ftp.err >> /tmp/ftp.failed if [ ! -s /tmp/ftp.failed ]; then echo "" else cat /tmp/ftp.err exit 1 fi if [ "$?" -eq 0 ] then echo " " echo "*** DONE TRANSFER OF OUTPUT FILE ***" else echo " " echo "Transfer of Output File Failed!" echo "Call Tech Support!" echo "*** Exitting Script On Failure!!!************" exit 1 fi else echo "Invalid file [$APPLTMP/$file]" exit 1; fi cp /tmp/ftp.err /tmp/ftp$file cp /tmp/ftp.failed /tmp/ftp$file done |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|