I send files by ftp using ksh script . The real Proplem is How to Know if the sent file sent OK or Not (As rcp command I was check ($?) to know the sent file correctly sent or not)?
Must use ftp command to test -e.g. ls
I realy used this solution inside my script ; But How I decide the result
(Found OR NotFound )To report in simply and readable Form to enduser .To
invoke this, the following was my way :
1- call ftp scrpt from a parent scrpt
2- redirect ALL ftp output to a file
3- put the file
4- run "ls" inside ftp & echo a messge conaining constant expr. to the output file
5- after ftp scrpt ends , the process reback to parent scrpt then I grep a line witch includes both constant "IS" and the sent file name because I noticed that when ls found file it prints the file name .
but I want more professional way .
echo "enter date ..\c" ; read dte ; export dte
if [ $dte ] ; then
echo ".. SENDING ...\c"
# folowing line calls ftp scrpt i named it SEND
/home2/flexuser/report/send >/home2/flexuser/report/send.log 2>&1
echo "Branches NOT sent "
grep IS /home2/flexuser/report/send.log |grep -v txt|cut -f8 -d" "
echo "Branches didnot respond "
grep respond /home2/flexuser/report/send.log
echo "Branches sent "
grep IS /home2/flexuser/report/send.log |grep txt |cut -f14 -d" "
echo "input is not proper "
echo " Press Enter To exit ..\c"
###FTP SEND SCRIPT ###############
for host in `cat /home2/flexuser/.netrc |cut -f2 -d" "`
brn=`grep $host /home2/flexuser/.netrc |cut -f8 -d " "`
ping $host 1 >/dev/null
case $? in
0)echo "\n Now you are sending $host";
ftp $host <<-ENDFTP
put br_rp$dte.$brn br_rp$dte.$brn.txt
!echo " IS The file br_rp$dte.$brn for $host Found ?\c"
echo " No respond from $host" ;;" >> /home2/flexuser/report/send_rep/noconect ;
Do you have a UNIX Question?
Unix Home: Unix System Administration
Hints and Tips