C Shell Scripts
Jump to navigation
Jump to search
These scripts must be executable.
$ chmod 775 myscript.com
Sample 1
[edit]This file aim2voi.com shows the use of command line arguments in a CSH script.
#!/bin/csh #------------------------------------------------------------------------------ onintr end if ($#argv < 1) goto usage #------------------------------------------------------------------------------ aix $1.aim > $1.dsc aic2voi $1.aim $1.voi goto end #------------------------------------------------------------------------------ usage: # echo "" echo "Usage:" echo "" echo "aim2voi aim_filename (without aim extension)" echo "will create a voi and dsc file from an aim" echo "" # exit #------------------------------------------------------------------------------ end: exit #------------------------------------------------------------------------------
Sample 2
[edit]Similar to above, but aim2bid.com generates a temporary file called stack which
is used as input.
#!/bin/csh
#------------------------------------------------------------------------------
onintr end
if ($#argv < 4) goto usage
#------------------------------------------------------------------------------
set i = $3
while ($i <= $4)
set nr = $i
if ($nr<10) set nr = "0"$nr""
if ($nr<100) set nr = "0"$nr""
# if ($nr<1000) set nr = "0"$nr""
echo "XY" >! stack
echo "$i" >> stack
echo "$5" >> stack
if ($6 != "") then
echo "0" >> stack
aio $1 "$2"_"$nr".bid 14 < stack
convert -size "$7" "$2"_"$nr".bid "$2"_"$nr"."$6"
\rm -f "$2"_"$nr".bid
else
echo "2" >> stack
aio $1 "$2"_"$nr".bid 14 < stack
endif
\rm -f stack
@ i = $i + 1
end
goto end
#------------------------------------------------------------------------------
usage:
#
echo ""
echo "Usage:"
echo ""
echo "aim2bid aim_filename bid_prefix first_slice last_slice scal_factor [form size])"
echo " (values are one-based) gif/tif/..."
echo ""
#
exit
#------------------------------------------------------------------------------
end:
exit
#------------------------------------------------------------------------------
Sample 3
[edit]An example where a sequence of commands are executed resulting in an e-mail to let the user know that their job is finished.
#!/bin/csh # nohup faim -s $1; /bin/csh -cbf "Mail -s 'JOB $1 FINISHED' boyd@kin < ~/adm/mailer/faimjob.txt" &
You would run this script called faim.com as follows
$ faim.com inputfile
Sample 4
[edit]This example uses two files. One called wrap.com is the base program that is called in
a more general program called wrap_all.com so that many different files can be processed
by the base script.
- wrap.com
#!/bin/csh echo "0" >! stack echo "0" >> stack echo "0" >> stack /home/skb/works/fio/aim_io $1.aim $1_sub.aim minimal 15 < stack /rm -f stack exit
- wrap_all.com
#!/bin/csh ~/works/com/wrap calgary_dog_aclx_03-04_med_fem_left ~/works/com/wrap calgary_dog_aclx_03-04_med_fem_right ~/works/com/wrap calgary_dog_aclx_03-04_med_tib_left ~/works/com/wrap calgary_dog_aclx_03-04_med_tib_right echo "DONE!" exit