The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-29-2006
RLatham20 RLatham20 is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 1
Exclamation Random files do not FTP in the shell script

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
  #2 (permalink)  
Old 06-29-2006
RTM's Avatar
RTM RTM is offline Forum Advisor  
Hog Hunter
  
 

Join Date: Apr 2002
Location: On my motorcycle
Posts: 3,039
The files in /tmp may still be open/being built - then the next time you run, those are okay and transfer and some other file is in the same state - open or being built.

Check the process that builds these files or for any processes that may have them open - if the file is open, you may not want to transfer until they are static.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:22 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0