how to run non-standard commands in bash script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to run non-standard commands in bash script?
# 8  
Old 08-03-2010
Quote:
Originally Posted by agama
I meant that set -x should be added inside of nwchem near the top (after the #!line if you are using that, otherwise as the first command). Sorry for the confusion.

You probably didn't get an error message this time round because the nwchem command after the 'set -x' was absorbed by the set command and there was no attempt to execute it.

Since you've said that you've been getting a 'not found' message, it does appear that it is a PATH issue, however from what you've posted it looks like you have your PATH setup to include the directory where nwchem exists.
Im not sure what is going on.
When I put set -x in there properly as you say, it gives the following for the lines where I specify the path and try to execute nwchem:
+ path=.:/opt/local/bin/x86_64:/opt/gridengine/bin/lx26-amd64:/opt/intel/impi/3.1/bin64:/usr/kerberos/bin:/usr/java/jdk1.5.0_10/bin:/opt/intel/itac/7.1/bin:/opt/intel/fce/10.1.011/bin:/opt/intel/idbe/10.1.011/bin:/opt/intel/cce/10.1.011/bin:/opt/globus/bin:/opt/globus/sbin:/opt/intel/clck/1.1:/usr/local/bin:/bin:/usr/bin:/opt/Bio/ncbi/bin:/opt/Bio/mpiblast/bin/:/opt/Bio/EMBOSS/bin:/opt/Bio/clustalw/bin:/opt/Bio/t_coffee/bin:/opt/Bio/phylip/exe:/opt/Bio/mrbayes:/opt/Bio/fasta:/opt/Bio/glimmer/bin:/opt/Bio/glimmer/scripts:/opt/Bio/gromacs/bin/:/opt/eclipse:/opt/ganglia/bin:/opt/ganglia/sbin:/opt/maven/bin:/opt/openmpi/bin/:/opt/rocks/bin:/opt/rocks/sbin:/usr/X11R6/bin:/usr/local/dislin/bin:/opt/local/share/nwchem/nwchem
+ nwchem SDDbeckehandh3_spin.nw
./nw_chem_DIMERscript.sh: line 152: nwchem: command not found



Also, when I submit the script by hand, the following message is given:
nwchem SDDBPW911_spin.nw
# of processors not specified. Defaulting to 1
Submitting NWCHEM job SDDBPW911_spin ....

Your job 4675247 ("SDDBPW911_spin.19706.script") has been submitted

The job number is just the number that it has going into the queue, but the number between spin. and .script corresponds to something else. I'm not sure what. Does this fact that it's going to a queuing system matter here? It's still executed from the shell with just the simple nwchem command after all...

---------- Post updated at 08:57 AM ---------- Previous update was at 08:54 AM ----------

Quote:
Originally Posted by skles
You can add path=$PATH:/opt/local/share/nwchem/nwchem in ~/.bash_profile
then you have two choice:
1 source ~/.bash_profile
so ,you can use your command now.

2 log out and then log in
then you can find it works
I added the path as you said. Here is what the ./bash_profile looks like now:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
path=$PATH:/opt/local/share/nwchem/nwchem
export PATH
unset USERNAME


Is this correct? I tried it as is and it didn't change anything.
# 9  
Old 08-04-2010
Does anyone have any other ideas about where I might look for answers to this question? I had always assumed that the problem would end here and that someone on this board would know the answer...
# 10  
Old 08-04-2010
Earlier you said you added this to your .sh script:
Quote:
path=$PATH:/opt/local/share/nwchem/nwchem
nwchem $basis_name$func_name$spin_name".nw"

This gives the error:
./nw_chem_DIMERscript.sh: line 152: nwchem: command not found
If "which nwchem" returns "/opt/local/share/nwchem/nwchem", this means nwchem is in "/opt/local/share/nwchem" -- so if you want to add this directory to the PATH, that section should read as follows:
Code:
PATH=$PATH:/opt/local/share/nwchem
nwchem $basis_name$func_name$spin_name".nw"

# 11  
Old 08-04-2010
Have you tried simply putting the full path in your bash script rather than changing the $PATH variable?
What I mean is, inside your script that creates the folders and such write

Code:
... make folders ...
/opt/local/share/nwchem/nwchem
... other stuff ...

This works fine for me. Below is a script named script that makes a directory and a file, and then runs nwchem. nwchem for me simply prints out "This is nwchem". Note that nwchem is called by its full path (~ is just a shortform for /Users/****/).

Code:
  1 #!/bin/bash
  2 mkdir newdir
  3 touch newdir/file1
  4 ~/Documents/nwchem/nwchem

output as follows

Code:
dhcp23:nwchem ******n$ ./script
This is nwchem
dhcp23:nwchem *****$ ls -l
total 40
drwxr-xr-x  3 ****  staff   102  4 Aug 12:20 newdir
-rwxr-xr-x  1 *****  staff  9560  4 Aug 12:17 nwchem
-rw-r--r--  1 ***** staff    81  4 Aug 12:17 nwchem.cxx
-rwxrwxrwx  1 *****  staff    71  4 Aug 12:18 script

nwchem is run and the directory and file inside it is created.
You may also want to check that you have execute permissions for nwchem.
If not, change it with chmod, chmod 744 nwchem will give you read write and execute permissions and others only read.
This User Gave Thanks to bluejayek For This Post:
# 12  
Old 08-04-2010
Quote:
Originally Posted by bluejayek
Have you tried simply putting the full path in your bash script rather than changing the $PATH variable?
What I mean is, inside your script that creates the folders and such write
That worked! Thanks so much! You've made my job 1000% easier.

Cheers,
EMF
# 13  
Old 08-05-2010
lol, the easy way is the best way.

Last edited by vistastar; 08-05-2010 at 02:31 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Run automated bash commands from sh login shell

I use plink.exe to automate remote commands that return data to Windows machines. This works well on newer servers running Red Hat since the commands were developed for bash and the designated user's login shell is bash. I need to also support older servers which are running Solaris 10 but the... (5 Replies)
Discussion started by: randman1
5 Replies

2. Shell Programming and Scripting

How to run several bash commands put in bash command line?

How to run several bash commands put in bash command line without needing and requiring a script file. Because I'm actually a windows guy and new here so for illustration is sort of : $ bash "echo ${PATH} & echo have a nice day!" will do output, for example:... (4 Replies)
Discussion started by: abdulbadii
4 Replies

3. IP Networking

How to run an script and its commands via proxy?

Hi, i used this tutorial which tells me to use following example command to proxify traffic from my linux export {http,https,ftp}_proxy=122.228.156.126:80 when i do this command from command line it works and then i curl http://site/ipcheck.php i see its proxified, which is what i want to... (5 Replies)
Discussion started by: postcd
5 Replies

4. Shell Programming and Scripting

Run commands in a script in different shells

Hi to all, i have the following problem... i want to run three commands in a script in different shells... the first command is running always and is needed for the second on to run properly... example # Procedure 1 xterm -e exec1 arg1 arg2 # Procedure 2 xterm -e exec2 arg1 arg2 #... (6 Replies)
Discussion started by: paladinaeon
6 Replies

5. Shell Programming and Scripting

[bash] run a shell who runs commands

Hi all. On X11 I'm on a shell ...shell_1 (/bin/bash). From here I want to open another shell window shell_2 who executes commands like "ls -l" or programs like ". /program"... so the "result" of commands shows in shell_2 window and not in shell_1. Is that possible ? (4 Replies)
Discussion started by: jerold
4 Replies

6. Shell Programming and Scripting

Logging ALL standard out of a bash script to a log file, but still show on screen

Is it possible to store all standard-out of a bash script and the binaries it calls in a log file AND still display the stdout on screen? I know this is possible to store ALL stdout/stderr of a script to a single log file like: exec 1>&${logFile} exec 2>&1 But running a script with the... (3 Replies)
Discussion started by: ckmehta
3 Replies

7. Shell Programming and Scripting

run commands within a script on certain days

Hi, please advise a script, something like this: If ; then do something else ( or for any other day of the week ) do otherthing fi Thanks (5 Replies)
Discussion started by: fed.linuxgossip
5 Replies

8. Shell Programming and Scripting

Run a shell script from one host which connext to remote host and run the commands

I want to write a script which would run from one host say A and connect to other remote host B and then run rest of commands in that host. I tried connecting from A host to B with SSH but after connecting to host B it just getting me inside Host B command prompt. Rest of the script is not running... (6 Replies)
Discussion started by: SN2009
6 Replies

9. Shell Programming and Scripting

how to make your bash script run on a machine with csh and bash

hi, i have a script that runs on bash and would like to run it on a machine that has csh and bash. the default setting on that machine is csh. i dont want to change my code to run it with a csh shell. is there any way i can run the script (written in bash) on this machine? in other words is there... (3 Replies)
Discussion started by: npatwardhan
3 Replies

10. Programming

code that reads commands from the standard i/p and executes the commands

Hello all, i've written a small piece of code that will read commands from standard input and executes the commands. Its working fine and is execting the commands well. Accepting arguments too. e.g #mkdir <name of the directory> The problem is that its not letting me change the directory i.e... (4 Replies)
Discussion started by: Phrozen Smoke
4 Replies
Login or Register to Ask a Question