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
TENTACLE_CLIENT(1)					   Client file transfer protocol					TENTACLE_CLIENT(1)

NAME
tentacle_client - a client file transfer protocol SYNOPSIS
tentacle_client <options> Tentacle is a client/server file transfer protocol that aims to be: - Executable programs or shell commands - System calls (functions provided by the kernel) - Library calls (functions within program libraries) Tentacle was created to replace more complex tools like SCP and FTP for simple file transfer/retrieval, and switch from authentication mechanisms like .netrc, interactive logins and SSH keys to X.509 certificates. Simple password authentication over a SSL secured connection is supported too. The client and server (TCP port 41121) are designed to be run from the command line or called from a shell script, and no configuration files are needed. Tentacle is now the default file transfer method for Pandora FMS and Babel Enterprise. Tentacle is implemented in Perl and ANSI C (Windows platforms included). You can download it and get more information at the official Sourceforge website http://tentacled.sourceforge.net/. OPTIONS
Tentacle Client options : -a address : Server address (default 127.0.0.1). -c : Enable SSL without a client certificate. -e cert : OpenSSL certificate file. Enables SSL. -f ca : Verify that the peer certificate is signed by a ca. -g : Get files from the server. -h : Show help. -k key : OpenSSL private key file. -p port : Server port (default 41121). -q : Quiet. Do now print error messages. -r number : Number of retries for network operations (default 3). -t time : Time-out for network operations in seconds (default 1s). -v : Be verbose. -w : Prompt for OpenSSL private key password. -x pwd : Server password. EXAMPLES
tentacle_client -a 192.168.1.1 -v /bin/bash Simple file transfer with maximum file size set to 1MB tentacle_client -a 192.168.1.1 -x password -v /bin/bash Simple file transfer with password authentication (not secure) tentacle_client -a 192.168.1.1 -x password -e cert.pem -k key.pem -v /bin/bash Secure file transfer with client certificate and password authentication NOTES
Tentacle requires Perl 5.8 or higher to works SEE ALSO
tentacle_server(1), pandora_server(1), pandora_agent(1) 0.2.0 2010-05-11 TENTACLE_CLIENT(1)
All times are GMT -4. The time now is 09:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy