Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

i'm getting bashed



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







BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org