Sponsored Content
Top Forums Shell Programming and Scripting Random files do not FTP in the shell script Post 302078313 by RLatham20 on Thursday 29th of June 2006 11:35:29 AM
Old 06-29-2006
Error 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
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ftp files inside a shell script

I have a shell script where I am trying to ftp some files but I get the error message "EOF unclosed" every time the script reaches the ftp section. Here is how my script is written. #more code up here rm -f $object >> $LOG_FILE 2>&1 fi #end of if done #end of for loop ... (5 Replies)
Discussion started by: matrix1067
5 Replies

2. Shell Programming and Scripting

Random parameters passing in FTP script

Hi I have a question. In the FTP script if we are passing all the required value like Hostname, username, password, Action(put or get), Filename, & mode(ascii or binary) through parameters then we have to pass these in the exact orders in which they are taken like if we defined Username=$2... (2 Replies)
Discussion started by: sourabhshakya
2 Replies

3. Shell Programming and Scripting

FTP random files

Hello everyone, What I'm trying to do is figure out how to ftp a set of random files each day about 50 or so maybe more or less. I have a folder on my server that gets about 1000 or so new files each day, each with today's date in the file name. We just want to take a sample each day for... (3 Replies)
Discussion started by: whegra
3 Replies

4. Shell Programming and Scripting

Getting a list of files on an ftp, via shell script...

G'day, I was wanting to write a shell script that checks an ftp server for the presence of new files, then get those files. In so much as the get, this is pretty straight forward, but I cannot work out how to get a list of files to check. Is it possible for a shell script to get the output of... (1 Reply)
Discussion started by: Elric of Grans
1 Replies

5. Shell Programming and Scripting

shell script to auto process ten random files and generate logs

Hello member's I'm learning to script in the ksh environment on a Solaris Box. I have 10 files in a directory that I need to pass, as input to a batch job one by one. lets say, the files are named as follows: abcd.txt ; efgh.bat ; wxyz.temp etc. (random filenames with varied extensions ).... (1 Reply)
Discussion started by: novice82
1 Replies

6. UNIX for Advanced & Expert Users

Shell script to ftp files from windows to unix

Hi , I need to ftp some input files from windows to unix server.All the files will be saved in the C drive in my machine.Currently all these files are transferring manually to the unix server.I need to write a shell script which ftp the files from windows to unix box.When I searched in the forum i... (1 Reply)
Discussion started by: kavithakuttyk
1 Replies

7. UNIX for Dummies Questions & Answers

ftp files from one server to another using shell script

Hi Guys Any Help I have created a spool file that i need to copy onto another server using FTP in a shell script both servers are linux (3 Replies)
Discussion started by: itai
3 Replies

8. Emergency UNIX and Linux Support

Shell script to get all the files from FTP server

Hi Guru's, I am new to UNIX. my requirement is to log on to FTP server and get all the .txt files. i have developed one script by searching some forums but getting error and not able to fix them. pls see below code. ftp -i-n<<EOF open $FTP_HOST... (30 Replies)
Discussion started by: arund_01
30 Replies

9. Shell Programming and Scripting

shell script to ftp multiple files

Hi, i use the below script to send a single file to remote server from linux. ftp -nvi <<!EOF open $Host_name user $USER_ID $PWD binary mput $file_name quit !EOF (where i... (2 Replies)
Discussion started by: pradebban
2 Replies

10. Shell Programming and Scripting

FTP in shell script and selecting files for upload

Hi, Im a newbie with programming and shell scripting. Im running OSX/Mac and Darwin. I would like to create a shell script that would : 1. Search a Volume and directory (including subdirectories) for a file that : * filename ends with ”_Highres.pdf” and * the file creation date of... (8 Replies)
Discussion started by: NickeZ28
8 Replies
DH_COMPRESS(1)							     Debhelper							    DH_COMPRESS(1)

NAME
dh_compress - compress files and fix symlinks in package build directories SYNOPSIS
dh_compress [debhelperoptions] [-Xitem] [-A] [file...] DESCRIPTION
dh_compress is a debhelper program that is responsible for compressing the files in package build directories, and makes sure that any symlinks that pointed to the files before they were compressed are updated to point to the new files. By default, dh_compress compresses files that Debian policy mandates should be compressed, namely all files in usr/share/info, usr/share/man, files in usr/share/doc that are larger than 4k in size, (except the copyright file, .html and other web files, image files, and files that appear to be already compressed based on their extensions), and all changelog files. Plus PCF fonts underneath usr/share/fonts/X11/ FILES
debian/package.compress These files are deprecated. If this file exists, the default files are not compressed. Instead, the file is ran as a shell script, and all filenames that the shell script outputs will be compressed. The shell script will be run from inside the package build directory. Note though that using -X is a much better idea in general; you should only use a debian/package.compress file if you really need to. OPTIONS
-Xitem, --exclude=item Exclude files that contain item anywhere in their filename from being compressed. For example, -X.tiff will exclude TIFF files from compression. You may use this option multiple times to build up a list of things to exclude. -A, --all Compress all files specified by command line parameters in ALL packages acted on. file ... Add these files to the list of files to compress. CONFORMS TO
Debian policy, version 3.0 SEE ALSO
debhelper(7) This program is a part of debhelper. AUTHOR
Joey Hess <joeyh@debian.org> 11.1.6ubuntu2 2018-05-10 DH_COMPRESS(1)
All times are GMT -4. The time now is 04:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy