Home » Infrastructure » Unix » ftp script
ftp script [message #367037] Wed, 23 August 2000 17:41 Go to next message
mimi
Messages: 11
Registered: August 2000
Junior Member
Urgent
I need to write a unix ftp script that picks files as soon as they arrive in certain directories in a database and send them to a remote database

The files will arrive as eg 1) UK_BAT
2) NE_BAT ETC

The UK will arrive in a directory x/k/unitedkindom
The NE will '' '' '' directory x/k/netherlands
when these files arrive, I want them to be ftp to remote database called waauyyy
and in a directory called l/k/Bat

Pls help me out
Re: ftp script [message #367053 is a reply to message #367037] Fri, 06 October 2000 03:53 Go to previous messageGo to next message
Sandeep Deshmukh
Messages: 13
Registered: October 2000
Junior Member
Please find scripts for ftp :

### Variables for data ###
### export not required if defined in same ### ### shell program
export UK_FILE_IN=/x/k/unitedkingdom
export NE_FILE_IN=/x/k/netherlands
export HOSTDIR=/l/k/Bat
export HOSTIPADDR=1.2.3.4
export HOSTUSER=USER
export HOSTPASS=PASS
export NO_SEC=10
export SEND_FLAG="N"
export FTP="ftp -nvd"

while true
do
if [[ -f $UK_FILE_IN ]]
then
FILE_TO_SEND=$UK_FILE_IN
SEND_FLAG="Y"
elif [[ -f $NE_FILE_IN ]]
then
FILE_TO_SEND=$NE_FILE_IN
SEND_FLAG="Y"
else
sleep $NO_SEC
fi;

if [[ $SEND_FLAG = "Y" ]]
then
FTP $HOSTIPADDR <<-ENDFTP 2>&1
user=$HOSTUSER $HOSTPASS
prompt off
put $FILE_TO_SEND $HOSTDIR
bye
ENDFTP
SEND_FLAG = "N"
fi;

done

Mezzie,Please note that -
1)The scripts don't have a loop breaking condition (in such case from_time to to_time does work.
2)To varify whether ftp is successful ,you probably need to append the script to write FTP log into a file & egreping "Transfer Complete" in it.

In case of further queries,feel free to ask.
Re: ftp script [message #367064 is a reply to message #367037] Wed, 18 October 2000 21:35 Go to previous message
Alan
Messages: 68
Registered: October 1999
Member
You might consider putting the machine name, user id and password into the $HOME directory file .netrc and set rw permissions for the user only (chmod go-rw .netrc). This will prevent the user id and password from being seen within the script.
You'll have to confirm the syntax for the .netrc entry, but I think it is:
machine IP address logon userid password password
Previous Topic: Oracle 7.3.4 update
Next Topic: Forms 6.0 on Unix
Goto Forum:
  


Current Time: Wed Apr 24 20:22:19 CDT 2024