LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Hi, I am a complete n00b in need of help executing her bash shell script. (https://www.linuxquestions.org/questions/linux-newbie-8/hi-i-am-a-complete-n00b-in-need-of-help-executing-her-bash-shell-script-536764/)

savoirefaire 03-12-2007 05:00 AM

Hi, I am a complete n00b in need of help executing her bash shell script.
 
I am working on my final year project in University. I am a Bio student and so no close to nothing when it comes to Linux.

I am running a simulation on a program called Amber 8 which runs on Linux. I have to run a series of fifteen shell scripts for a step (minimization) in my project and I am ages ages behind.

I managed to run my very first file a couple of weeks ago and it looks like this:

Code:

#!/bin/bash

cd /home/sandhya/p53

cp p53bp2.restrt refc

rm -f myprocfile

LSB_HOST=1

for i in $LSB_HOST; do
  HN=`echo $i|cut -f 1 -d .`
  echo "/usr/local/amber8/exe/sander -O -i newmd.in -o md1.out -p p53bp2.parmtop -c p53bp2.restrt -r restrt1 -ref refc  -x mdcrd1 -v mdvel1 -e mden1 -inf mdinfo " >> myprocfile
done

chmod a+x myprocfile
cat myprocfile

I know it was successful as I can see both my input and output files in my directory. In my subsequent step which needs the files generated in this shell script and the addition of an input file h2.in (which I have in my directory), I modified my script in accordance to the one above, changing only filenames etc (as I was recommended to). However, I get the -bash: ./h2.sh: Permission denied
response.

My script, h2.sh looks like this:
Code:

#!/bin/bash

cd /home/sandhya/p53

cp restrt1 refc1

rm -f myprocfile

LSB_HOST=1

for i in $LSB_HOST; do
  HN=`echo $i|cut -f 1 -d .`
  echo "/usr/local/amber8/exe/sander -O -i h2.in -o md2.out -p p53bp2.parmtop -c restrt1 -r restrt2 -ref refc1  -x mdcrd2 -v mdvel2 -e mden2 -inf mdinfo1 " >> myprocfile
done

chmod a+x myprocfile
cat myprocfile

I am completely LOST at the moment but I have two questions.
a) what am I missing, doing wrong in my second script that I should be aware of and be careful of when I do the rest of my fifteen subsequent steps?
b) is the problem also in the fact that i am using "./h1.sh" as an invocation? Because i have a feeling that I may have forgotten how to run a shell script altogether (it's been two weeks since i last saw how to)?

Please please, someone help ASAP. I am very very doomed for my project. I am ready to provide more infos if any are lacking in this very desperate plea of a post.
Thanks alot. I am deeply appreciative of all those of you who can help.

greengrocer 03-12-2007 05:27 AM

Hi savioufaire,

I never went to University but I think I can help with your problem.

Ok, your using "born again shell", so you should be able to execute your shell scripts with the sh command, for example:

Code:

sh <filename>

Hope that helps,
Regards,
Greenie

savoirefaire 03-12-2007 05:39 AM

Hello!

I did as you mentioned and while i got this
Code:

sandhya@sbscluster p53 $ sh h2.sh
/usr/local/amber8/exe/sander -O -i h2.in -o md2.out -p p53bp2.parmtop -c restrt1 -r restrt2 -ref refc1  -x mdcrd2 -v mdvel2 -e mden2 -inf mdinfo1

BUT upon checking my directory, I do not see any of the output files, md2.out for example.

:confused: :(

greengrocer 03-12-2007 06:06 AM

Hi,

Well I wondered about your script, because I thought why would you want to create a file called "myprocfile" that contains only the content of this line:

Code:

/usr/local/amber8/exe/sander -O -i h2.in -o md2.out -p p53bp2.parmtop -c restrt1 -r restrt2 -ref refc1  -x mdcrd2 -v mdvel2 -e mden2 -inf mdinfo1

Do you think that the echo command in your script should be removed?

Perhaps make a backup folder first, called "projectbackup";

Code:

mkdir /usr/local/amber8/exe/projectbackup
then change directory to where your files are (using the 'cd' command;

and then copy all of your files to your projectbackup folder;

Code:

cp * /usr/local/amber8/exe/projectbackup
now remove the echo command from this line in your script;

Code:

  echo "/usr/local/amber8/exe/sander -O -i h2.in -o md2.out -p p53bp2.parmtop -c restrt1 -r restrt2 -ref refc1  -x mdcrd2 -v mdvel2 -e mden2 -inf mdinfo1 " >> myprocfile
so that the line looks like this;

Code:

  /usr/local/amber8/exe/sander -O -i h2.in -o md2.out -p p53bp2.parmtop -c restrt1 -r restrt2 -ref refc1  -x mdcrd2 -v mdvel2 -e mden2 -inf mdinfo1 >> myprocfile
and then run the script again.

Regards,
Greenie

bigrigdriver 03-12-2007 06:14 AM

I don't know anything about Amber8, but I'll take a stab at it.

After running the first script, run 'ls -l' on the directory containing the created file. Who is the owner? If Amber8 owns the file, your chmod command won't change the execute permission, and the next script will fail with a 'permission denied' message.

Your first script will have to change ownership (chown <username> <filename>) before the chmod command will work. Then the second script may work.


All times are GMT -5. The time now is 11:48 PM.