i'm getting bashed
Eric Chadbourne
EChadbourne-3av5VAs6qClGBRGhe+f61g at public.gmane.org
Thu May 14 15:18:08 EDT 2009
Hi all.
I'm writing a script to move some files around via SFTP. First part of
the script gets a file. Second part of the script is an if statement
verifying the file is on our server and sending out an email. If I run
the scripts separately they work. If I try to put them into one shell
script it hangs on the 'if' statement. No error, just hangs. This is
on SunOS Bash version 2.05. Thanks for any tips. - Eric C.
# part 1
sftp $ftp_server <<EOT
cd $a_path
get a_file.*.zip
rm a_file.*.zip
exit
EOT
# part 2
found_file=0 # got this trick from a blu member
found_file=$(find . -type f -name " a_file.*.zip " -exec echo 1 \; |
uniq)
if [ "$found_file" = 1 ] ; then
# unzip file. rename.
unzip a_file.*.zip
rm a_file.*.zip
old_file_name=$(basename a_file.*.txt)
new_file_name=$(basename a_file.*.txt .txt) # tricky
mv a_file.*.txt $new_file_name.sly
# email file moved
/bin/mailx -s 'super file script' $1 <<-EOT
This is a message from sphere_sync_get.sh.
The file $old_file_name has been transferred.
Thanks.
EOT
else
# email no file moved
/bin/mailx -s 'not so super script' $1 <<-EOT
Oops.
Thanks.
EOT
fi
More information about the Discuss
mailing list