Dear All
Due to popular demand, I have written two shell scripts to ease the
transfer of nmr datasets to and from the floppy disk on the
ASPECTstation. These scripts are called "tofloppy" and "fromfloppy" and
are attached to the end of this mail message. Both scripts can take
input as command line arguments, or by prompting you interactively.
Extract these scripts and call them tofloppy and fromfloppy. Now become
root, copy them into /usr/bin and type:
chmod 755 tofloppy
chmod 755 fromfloppy
This will let anyone use the commands tofloppy or fromfloppy from the
unix prompt.
Both of these commands can take input from the command line or by
prompting you interactively,
e.g.:
tofloppy guest spld0 1 1 -w
will copy all files necessary for WIN-NMR 1D for the sample spld0
experiment and process 1 for the user guest to the floppy disk.
tofloppy guest spld0 1 1
will copy all files for the sample spld0 experiment and process 1 for
the user guest to the floppy disk.
If you omit any arguments, you are prompted for them interactively,
e.g.
tofloppy jack
tofloppy
will prompt you for user, sample, expt, and process number. The first
example will set the default value for user to "jack".
If you specify the -p flag (not available for the fromfloppy command),
then the program will prompt for each file to copy.
For more information, look at the comments at the top of each file
------------------------ Start of tofloppy -----------------------------
#!/bin/sh
# tofloppy
# Script to copy a dataset to a floppy disk on the Aspect Station.
# You can either specify the dataset to copy as command line arguments
# (in the following order: user sample expno procno)
# or the program prompts for these values.
#
# By default, the script copies ALL of the files in the EXPNO and
# PROCNO directories. You can change this behavior by specifying an
# option anywhere on the command line. The last option specified takes
# precedence.
#
# -w or -W : Copy only the fid, acqu, acqus, 1i, 1r, proc, procs,
# and intrng files (if they exist). This option copies
# the minimum files needed to run 1D WIN-NMR.
#
# -p or -P : Prompts for the files to copy.
#
# Written by C. N. Jarman 03/31/94
#
# Initialize shell variables:
#
options="A"
count=0
user="guest"
disk="/usr/u/data/guest/nmr"
sample="dEfAuLt"
expno=1
procno=1
if [ $# -ne 0 ]; then
for arg
do
case "$arg" in
#
# Command Line options:
#
-*)
if [ $arg = "-p" -o $arg = "-P" ]; then
options="P"
elif [ $arg = "-w" -o $arg = "-W" ]; then
options="W"
fi
;;
#
# Command Line Arguments
#
*)
count=`expr $count + 1`
case "$count" in
1) user=$arg
disk="/usr/u/data/$user/nmr" ;;
2) sample=$arg ;;
3) expno=$arg ;;
4) procno=$arg ;;
*) echo "ignoring extra argument $arg" ;;
esac
;;
esac
done
fi
if [ "$count" -lt 4 ]; then
input="y"
else
input="n"
fi
try="again"
while [ "$try" = "again" ]; do
ans="n"
while [ $ans = "n" -o $ans = "N" ]; do
if [ "$input" = "y" ]; then
echo "List of valid users follows: "
/bin/ls -CF /usr/u/data
echo "Please enter user [$user] \c"
read arg
if [ -n "$arg" ]; then
user=$arg
disk="/usr/u/data/$user/nmr"
fi
fi
while [ ! -d $disk ]; do
echo "Invalid user!"
echo "List of valid users follows: "
/bin/ls -CF /usr/u/data
echo "Please re-enter! \c"
read arg
if [ -n "$arg" ]; then
user=$arg
disk="/usr/u/data/$user/nmr"
fi
input="y"
done
if [ "$input" = "y" ]; then
echo "List of valid samples follows: "
/bin/ls -CF $disk
echo "Please enter sample [$sample] \c"
read arg
if [ -n "$arg" ]; then
sample=$arg
fi
fi
while [ ! -d $disk/$sample ]; do
echo "Invalid sample!"
echo "List of valid samples follows: "
/bin/ls -CF $disk
echo "Please re-enter! \c"
read arg
if [ -n "$arg" ]; then
sample=$arg
fi
input="y"
done
if [ "$input" = "y" ]; then
echo "List of valid expnos follows: "
/bin/ls -CF $disk/$sample
echo "Please enter expno [$expno] \c"
read arg
if [ -n "$arg" ]; then
expno=$arg
fi
fi
while [ ! -d $disk/$sample/$expno ]; do
echo "Invalid expno!"
echo "List of valid expnos follows: "
/bin/ls -CF $disk/$sample
echo "Please re-enter! \c"
read arg
if [ -n "$arg" ]; then
expno=$arg
fi
input="y"
done
if [ "$input" = "y" ]; then
echo "List of valid procnos follows: "
/bin/ls -CF $disk/$sample/$expno/pdata
echo "Please enter procno [$procno] \c"
read arg
if [ -n "$arg" ]; then
procno=$arg
fi
fi
while [ ! -d $disk/$sample/$expno/pdata/$procno ]; do
echo "Invalid procno!"
echo "List of valid procnos follows: "
/bin/ls -CF $disk/$sample/$expno/pdata
echo "Please re-enter! \c"
read arg
if [ -n "$arg" ]; then
procno=$arg
fi
input="y"
done
if [ "$input" = "y" ]; then
echo "Files will be copied from directories "
echo "$disk/$sample/$expno and"
echo "$disk/$sample/$expno/pdata/$procno"
echo "Is this O.K. [Y/n] ? \c"
read ans
if [ -z "$ans" ]; then
ans="y"
fi
else
ans="y"
fi
done
#
# Delete the .mcwd file in the user's home directory. This file is
# created by the mcd command.
#
if [ -f $HOME/.mcwd ]; then
/bin/rm $HOME/.mcwd
fi
/usr/bin/mmd -v $sample
/usr/bin/mcd $sample
/usr/bin/mmd -v $expno
/usr/bin/mcd $expno
echo "Copying aquisition data from $disk/$sample/$expno "
cd $disk/$sample/$expno
if [ $options = "P" ]; then
for file in `/bin/ls`
do
echo "Copy file $file [Y/n]? \c"
read ans
if [ -z "$ans" ]; then
/usr/bin/mcopy $file a:
elif [ "$ans" != "n" -a "$ans" != "N" ]; then
/usr/bin/mcopy $file a:
fi
done
elif [ "$options" = "W" ]; then
for file in fid acqu acqus
do
if [ -f "$file" ]; then
/usr/bin/mcopy $file a:
fi
done
else
/usr/bin/mcopy * a:
fi
/usr/bin/mmd -v pdata
/usr/bin/mcd pdata
/usr/bin/mmd -v $procno
/usr/bin/mcd $procno
echo "Copying processed data from $disk/$sample/$expno/pdata/$procno"
cd pdata/$procno
if [ "$options" = "P" ]; then
for file in `/bin/ls`
do
echo "Copy file $file [Y/n] ? \c"
read ans
if [ -z "$ans" ]; then
/usr/bin/mcopy $file a:
elif [ "$ans" != "n" -a "$ans" != "N" ]; then
/usr/bin/mcopy $file a:
fi
done
elif [ $options = "W" ]; then
for file in 1r 1i proc procs intrng
do
if [ -f $file ]; then
/usr/bin/mcopy $file a:
fi
done
else
/usr/bin/mcopy * a:
fi
if [ "$input" = "y" ]; then
echo "Copy another dataset [y/N] ? \c"
read ans
if [ -z "$ans" ]; then
ans="n"
fi
else
ans="n"
fi
if [ $ans = "n" -o $ans = "N" ]; then
try="no"
else
input="y"
fi
done
#
# Delete the .mcwd file in the user's home directory. This file is
# created by the mcd command.
#
/bin/rm $HOME/.mcwd
-------------------------- End of tofloppy -----------------------------
---------------------- Start of fromfloppy -----------------------------
#!/bin/sh
#
# Script to copy a dataset from a floppy disk to the Aspect Station.
# You can either specify the dataset to copy as command line arguments
# (in the following order: user sample expno procno)
# or the program prompts for these values.
#
# By default, the script copies ALL of the files in the EXPNO and
# PROCNO directories. You can change this behavior by specifying an
# option anywhere on the command line. The last option specified takes
# precedence.
#
# -w or -W : Copy only the fid, acqu, acqus, 1i, 1r, proc, procs,
# and intrng files (if they exist). This option copies
# the minimum files needed to run 1D WIN-NMR.
#
# Written by C. N. Jarman 03/31/94
#
# Initialize shell variables:
#
options="A"
count=0
user="guest"
disk="/usr/u/data/guest/nmr"
sample="dEfAuLt"
expno=1
procno=1
if [ $# -ne 0 ]; then
for arg
do
case "$arg" in
#
# Command Line options:
#
-*)
if [ $arg = "-w" -o $arg = "-W" ]; then
options="W"
fi
;;
#
# Command Line Arguments
#
*)
count=`expr $count + 1`
case "$count" in
1) user=$arg
disk="/usr/u/data/$user/nmr" ;;
2) sample=$arg ;;
3) expno=$arg ;;
4) procno=$arg ;;
*) echo "ignoring extra argument $arg" ;;
esac
;;
esac
done
fi
if [ "$count" -lt 4 ]; then
input="y"
else
input="n"
fi
try="again"
while [ "$try" = "again" ]; do
ans="n"
while [ $ans = "n" -o $ans = "N" ]; do
#
# Delete the .mcwd file in the user's home directory.
#
if [ -f $HOME/.mcwd ]; then
/bin/rm $HOME/.mcwd
fi
if [ "$input" = "y" ]; then
echo "List of valid users on Aspectstation follows: "
/bin/ls -CF /usr/u/data
echo "Please enter user [$user] \c"
read arg
if [ -n "$arg" ]; then
user=$arg
disk="/usr/u/data/$user/nmr"
fi
fi
while [ ! -d $disk ]; do
if [ "$input" = "n" ]; then
echo "Invalid user $user".
echo "List of users on Aspectstation follows: "
/bin/ls -CF /usr/u/data
fi
echo "Please re-enter! \c"
read arg
if [ -n "$arg" ]; then
user=$arg
disk="/usr/u/data/$user/nmr"
fi
input="y"
done
if [ "$input" = "y" ]; then
echo "List of samples on floppy follows: "
mdir | tail +4|grep -v "File(s)"|cut -f1 -d" " -|pr -l1 -t -5
echo "Please enter sample [$sample] \c"
read arg
if [ -n "$arg" ]; then
sample=$arg
fi
fi
while [ "`/usr/bin/mcd "$sample" 2>&1`" != "" ]; do
if [ "$input" = "n" ]; then
echo "Invalid sample $sample".
echo "List of samples on floppy follows: "
mdir | tail +4|grep -v "File(s)"|cut -f1 -d" " -|pr -l1 -t -5
fi
echo "Please re-enter ! \c"
read arg
if [ -n "$arg" ]; then
sample=$arg
fi
input="y"
done
if [ "$input" = "y" ]; then
echo "List of expnos on floppy follows: "
mdir | tail +6|grep -v "File(s)"|cut -f1 -d" " -|pr -l1 -t -5
echo "Please enter expno [$expno] \c"
read arg
if [ -n "$arg" ]; then
expno=$arg
fi
fi
while [ "`/usr/bin/mcd "$expno" 2>&1`" != "" ]; do
if [ "$input" = "n" ]; then
echo "Invalid expno $expno".
echo "List of expnos on floppy follows: "
mdir | tail +6|grep -v "File(s)"|cut -f1 -d" " -|pr -l1 -t -5
fi
echo "Please re-enter ! \c"
read arg
if [ -n "$arg" ]; then
expno=$arg
fi
input="y"
done
/usr/bin/mcd pdata
if [ "$input" = "y" ]; then
echo "List of procnos on floppy follows: "
mdir | tail +6|grep -v "File(s)"|cut -f1 -d" " -|pr -l1 -t -5
echo "Please enter procno [$procno] \c"
read arg
if [ -n "$arg" ]; then
procno=$arg
fi
fi
while [ "`/usr/bin/mcd "$procno" 2>&1`" != "" ]; do
if [ "$input" = "n" ]; then
echo "Invalid procno $procno".
echo "List of procnos on floppy follows: "
mdir | tail +6|grep -v "File(s)"|cut -f1 -d" " -|pr -l1 -t -5
fi
echo "Please re-enter ! \c"
read arg
if [ -n "$arg" ]; then
procno=$arg
fi
input="y"
done
if [ "$input" = "y" ]; then
echo "Files will be copied from the PC floppy directories "
echo "$sample/$expno and"
echo "$sample/$expno/pdata/$procno"
echo "to the Aspectstation nmr directory"
echo "$disk"
echo "Is this O.K. [Y/n] ? \c"
read ans
if [ -z "$ans" ]; then
ans="y"
fi
else
ans="y"
fi
done
#
# Delete the .mcwd file in the user's home directory.
#
if [ -f $HOME/.mcwd ]; then
/bin/rm $HOME/.mcwd
fi
echo "Copying aquisition data from $sample/$expno "
if [ ! -d $disk/$sample ]; then
mkdir $disk/$sample
fi
if [ ! -d $disk/$sample/$expno ]; then
mkdir $disk/$sample/$expno
fi
cd $disk/$sample/$expno
/usr/bin/mcd $sample
/usr/bin/mcd $expno
if [ "$options" = "W" ]; then
for file in fid acqu acqus
do
/usr/bin/mcopy a:$file .
done
else
/usr/bin/mcopy a:* .
fi
if [ ! -d $disk/$sample/$expno/pdata ]; then
mkdir $disk/$sample/$expno/pdata
fi
if [ ! -d $disk/$sample/$expno/pdata/$procno ]; then
mkdir $disk/$sample/$expno/pdata/$procno
fi
echo "Copying processed data to $disk/$sample/$expno/pdata/$procno"
cd $disk/$sample/$expno/pdata/$procno
/usr/bin/mcd pdata
/usr/bin/mcd $procno
if [ $options = "W" ]; then
for file in 1r 1i proc procs intrng
do
/usr/bin/mcopy a:$file .
done
else
/usr/bin/mcopy a:* .
fi
if [ "$input" = "y" ]; then
echo "Copy another dataset [y/N] ? \c"
read ans
if [ -z "$ans" ]; then
ans="n"
fi
else
ans="n"
fi
if [ $ans = "n" -o $ans = "N" ]; then
try="no"
else
input="y"
fi
done
#
# Delete the .mcwd file in the user's home directory. This file is
# created by the mcd command.
#
/bin/rm $HOME/.mcwd
------------------------ End of fromfloppy -----------------------------
I hope you find these scripts helpful,
Best regards,
Clive Jarman
-- ================================================================== ... ... Clive Nicholas Jarman Ph.D . . . . Software Support Specialist . * . . Bruker Instruments, Inc. . . . Billerica, MA 01821, USA . . . . . BRUKER . (508) 667-9580 Ext. 231, 233 Phone . . . . (508) 663-9177 FAX . . . cnj@bruker.com e-mail . * . . software@bruker.com e-mail ... ... support@bruker.com e-mail =================================================================