Click to See Complete Forum and Search --> : ftp script not working please help


100prcnt Marine
02-03-2006, 08:40 PM
been working on this for a while. can someone have a look with fresh eyes/?thanks

goodcopy=N
count=0
while [ $goodcopy = N ]
do
lftp -e "get /storage/whitepaper/disk/IBMTS2TB.pdf -o ibmfile.pdf;bye" -u anonymous,2 ftp://ftp.boulder.ibm.com
if [ $? = 0 ]
then
$goodcopy=Y
echo "File successfully copied"
fi
if [ $goodcopy = "N" ]
then
sleep 300
count= $count + 1
fi
if [ $count = 5 ]
then
$goodcopy=Y
echo "Cannot copy file after 6 attempts"
fi
done
tar -czf `date +hw%y%m%d%H%M`.tgz ibmfile.pdf && rm ibmfile.pdf
find . -atime +30 -exec rm -f -v '{}' \;
exit 0

bwkaz
02-04-2006, 10:02 AM
Well, I was going to recommend using code tags to preserve your indentation. Then I went to edit your post to add them, and I realized that there was no indentation! No wonder you're running into bugs; you can't even see where if and for blocks start and end.

Recommendations:

1) Reformat the source. At the very minimum, reindent it. If you don't want to bother with this manually, (g)vim and emacs both have auto-indent modes that understand shell syntax, when to indent, and by how much.

(g)vim will automatically reindent an entire file by going into command mode and doing a "ggVG=" -- gg goes to the start of the file, V turns on visual-full-line mode, G goes to the end of the file (thus selecting all of it), and = does the reindentation. It will use your current "shiftwidth", "expand-tabs", and "tabstop" settings to decide how far to indent each level, whether to turn a run of spaces into a tab at all, and how many spaces to use if it does, respectively.

Emacs probably has something similar, but I don't know how to do it.

2) Once you've done that, if you can't figure out the problem, post what the problem is -- don't just say "I'm having a problem, can someone look at this". We have no idea what's happening, and what's happening almost always indicates what's wrong.

(Snide remark: Yes, someone can have a look at it. In fact I just did. Happy? :p)