Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is this script correct?

Status
Not open for further replies.

MadanB

IS-IT--Management
Feb 11, 2002
88
0
0
Hi All,

Just wanted to know if this script looks good to the experts. It's working but I'm just not sure. All I'm trying to do is move data via ftp from one machine to another.

TIA!

#Begin Script

cd $DATA

STRING=`file_system -from "Select Image Files" -max 50 *.ima`

STUDY=`echo $STRING | cut -d '/' -f4`

cd $STUDY

for i in $STRING ; do
filebase=`basename $i`
outfilebase=`echo $filebase | cut -d'.' -f1`.dcm
echo $filebase

echo "Conversion only..."
posiDicom -unsign -slice -amsNO -in $filebase -out $outfilebase
ierr=$?

# If we encountered an error during this iteration, then quit now, since subsequent iterations
# will probably also fail.
if [ $ierr -ne 0 ]; then
break
fi
done


if [ -f STUDY_LIST_FTP.log ]; then
rm STUDY_LIST_FTP.log
fi

ls -1 *.dcm > STUDY_LIST_FTP.log

textview -log STUDY_LIST_FTP.log

if [ $? -ne 0 ]; then
exit 1
fi

# ---- ftp-put -------

WHATAMI=`basename $0`

usage()
{
echo
echo Usage: $WHATAMI - you must be in the STUDY directory!
echo
}

if [ "$STUDY" = "" ]; then
usage
exit 1
fi

if [ ! -d "$DATA/$STUDY" ]; then
echo Error: \"${DATA}/${STUDY}\" not found.
exit 1
fi


SITE=192.168.20.4
USER=ftp
PASSWORD=Power

ftp -v -n -i $SITE <<EOF
user $USER $PASSWORD
mkdir $STUDY
cd $STUDY
lcd $DATA/$STUDY
binary
mput *.dcm
quit
EOF

exit $?

 
Well, it *looks* alright, but it's kind of hard to say when we don't know what things like file_system and posiDicom are doing. Why do you ask, is it giving you trouble? If so, where?

Annihilannic.
 
Thanks for the reply. file_system is just a variable and posiDicom is a function to convert images.

What I was really getting at was is this script efficent enough? I was trying to see if there was a better way to do this.
 
I don't see anything that's obviously inefficient, so it should be fine!

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top