Unix Programming - script advice

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > February 2006 > script advice





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author script advice
nkomli@gmail.com

2006-02-14, 5:54 pm

I'm trying to use a script to automate some Terminal command line work
I'm doing. Basically I'm inputting a filename, then running one set of
files with the sander program to generate an rst file used to start a
loop that will run the sander program again five times with other sets
of files. Since I don't have experience making scripts I'd like to show
what I've got so far to see if there are any mistakes. I don't know if
the filenames I'm using would work...

#!/bin/csh
set AMBERHOME="/usr/local/AMBER8"
set MDSTARTJOB=2
set MDENDJOB=6
set MDCURRENTJOB=$MDSTARTJOB
set MDINPUT=1

echo -n "enter filename"
$filename=<STDIN>
chop($filename);

echo -n "Starting Script at: "
date
echo ""

echo -n "Warming started at: "
date
$AMBERHOME/exe/sander -O -i hot.in \
-o hot$filename.out \
-p $filename.prmtop \
-c $filename.rst \
-r $filename$MDINPUT.rst \
-x hot$filename.mdcrd

echo -n "Job hot$filename finished at: "
date

while ( $MDCURRENTJOB <= $MDENDJOB )
echo -n "Job $MDCURRENTJOB started at: "
date
@ MDINPUT = $MDCURRENTJOB - 1
$AMBERHOME/exe/sander -O -i mdp53.in \
-o $filename$MDCURRENTJOB.out \
-p $filename.prmtop \
-c $filename$MDINPUT.rst \
-r $filename$MDCURRENTJOB.rst \
-x $filename$MDCURRENTJOB.mdcrd
gzip -9 -v $filename$MDCURRENTJOB.mdcrd
echo -n "Job $MDCURRENTJOB finished at: "
date
@ MDCURRENTJOB = $MDCURRENTJOB + 1
end
echo "ALL DONE"

Barry Margolin

2006-02-15, 3:03 am

In article <1139954241.471793.228800@g43g2000cwa.googlegroups.com>,
nkomli@gmail.com wrote:

> I'm trying to use a script to automate some Terminal command line work
> I'm doing. Basically I'm inputting a filename, then running one set of
> files with the sander program to generate an rst file used to start a
> loop that will run the sander program again five times with other sets
> of files. Since I don't have experience making scripts I'd like to show
> what I've got so far to see if there are any mistakes. I don't know if
> the filenames I'm using would work...
>
> #!/bin/csh


It's really not recommended to use csh for scripting. See

http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

> set AMBERHOME="/usr/local/AMBER8"


In csh you have to have spaces around the '=', i.e.

set AMBERHOME = /usr/local/AMBER8

> set MDSTARTJOB=2
> set MDENDJOB=6
> set MDCURRENTJOB=$MDSTARTJOB
> set MDINPUT=1
>
> echo -n "enter filename"
> $filename=<STDIN>
> chop($filename);


These last two lines are perl, not csh! The csh syntax is:

set filename = $<

>
> echo -n "Starting Script at: "
> date
> echo ""
>
> echo -n "Warming started at: "
> date
> $AMBERHOME/exe/sander -O -i hot.in \
> -o hot$filename.out \
> -p $filename.prmtop \
> -c $filename.rst \
> -r $filename$MDINPUT.rst \
> -x hot$filename.mdcrd
>
> echo -n "Job hot$filename finished at: "
> date
>
> while ( $MDCURRENTJOB <= $MDENDJOB )
> echo -n "Job $MDCURRENTJOB started at: "
> date
> @ MDINPUT = $MDCURRENTJOB - 1
> $AMBERHOME/exe/sander -O -i mdp53.in \
> -o $filename$MDCURRENTJOB.out \
> -p $filename.prmtop \
> -c $filename$MDINPUT.rst \
> -r $filename$MDCURRENTJOB.rst \
> -x $filename$MDCURRENTJOB.mdcrd
> gzip -9 -v $filename$MDCURRENTJOB.mdcrd
> echo -n "Job $MDCURRENTJOB finished at: "
> date
> @ MDCURRENTJOB = $MDCURRENTJOB + 1
> end
> echo "ALL DONE"


--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com