MadanB
IS-IT--Management
- Feb 11, 2002
- 88
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 $?
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 $?