UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2008-03-14 07:54 PM

criddel
Member
Registered: 2007-08-24
Posts: 4

Re: FTP script - Log files gone wrong

I have this script that FTPs some files and creates a couple of log files and then edits those files and moves them around a bit. At least it's supposed to it's not working the way I want. I'm pretty new to this stuff so I was just wondering if someone wouldn't mind taking a look at it to see where I went wrong or maybe suggest a better route. Thanks in advance.

P.S. The script is called ftpawards.sh

#!/bin/sh

mv /data/CYPRUS/FA.DIR/logfile \
/data/CYPRUS/FA.DIR/Awardslog/logfile`date +"%m%d%y"`

exec >> /data/CYPRUS/FA.DIR/logfile 2>&1
ftp -i -n -v << EOF
open 192.168.75.62
user Uname Pword
cd 'ECD.PL0482'
lcd /data/CYPRUS/FA.DIR/
prompt
ascii
mput TGP0482*
bye

echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=" >> /data/CYPRUS/FA.DIR/logfile
echo "Transfer Date - `date +'%m-%d-%y'`" >> /data/CYPRUS/FA.DIR/logfile

mv /data/CYPRUS/FA.DIR/PEMCO* /data/CYPRUS/FA.DIR/Awardslog/
grep booger /data/CYPRUS/FA.DIR/logfile || echo "PEMCO Transfer Failed"\
 >> /data/CYPRUS/FA.DIR/PEMCOerrlog`date +"%m%d%y"`
cp /data/CYPRUS/FA.DIR/PEMCO* /data/CYPRUS/_HOLD_/

Offline

#2 2008-03-14 08:00 PM

criddel
Member
Registered: 2007-08-24
Posts: 4

Re: FTP script - Log files gone wrong

Offline

#3 2008-03-14 09:58 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,847
Website

Re: FTP script - Log files gone wrong

You use a "<<EOF" here-document, but never actually give the "EOF" terminator
anywhere...  I think you want an "EOF" line after your "bye" command...

Also, for your trailing "echo"s, you don't want to redirect them to the log file, since
your previous "exec" trick already is redirecting all of your script's output there anyway,
so just simply do the echo with no redirection...  (As it is now, you might have issues
with flushing, so that output gets mixed up and overwrites each other...)

As for your grep of 3 occurances, just use "grep -c" to obtain a count of matching
lines, then you can test that value with normal shell test syntax...

Offline

Board footer

Powered by FluxBB