unzip, date, etc not available from scripts

Reply

Join Date: Jul 2008
Posts: 11
Reputation: nikhil.laghave is an unknown quantity at this point 
Solved Threads: 0
nikhil.laghave nikhil.laghave is offline Offline
Newbie Poster

unzip, date, etc not available from scripts

 
0
  #1
Mar 19th, 2009
Hello,

I am a newbie and do not have any shell script experience. I am trying to call a script from inside a fortran call using the call system(./script).

Now this script runs ok when run from command line, but when called from the fortran call, i get errors for unzip, date etc. i.e these commands cannot be found.

Do I need to do something additional to get these commands to run ? I need to unzip a few files inside the script, hence its necessary that this works from the system call.

Thanks,
Nikhil
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,639
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 283
Moderator
masijade's Avatar
masijade masijade is offline Offline
Posting Maven

Re: unzip, date, etc not available from scripts

 
0
  #2
Mar 19th, 2009
They don't have a full environment. Set the environment variables you need (such as PATH) in the script.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 92
Reputation: prushik is on a distinguished road 
Solved Threads: 4
prushik prushik is offline Offline
Junior Poster in Training

Re: unzip, date, etc not available from scripts

 
0
  #3
Mar 19th, 2009
or you can give full paths in your script.
e.g.
/usr/bin/less instead of less

I'm sure you don't use less, but its an example

the best thing to do is set the environment variables in your script, like masijade said:

PATH=$PATH:/usr/bin:/usr/sbin:/sbin
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 11
Reputation: nikhil.laghave is an unknown quantity at this point 
Solved Threads: 0
nikhil.laghave nikhil.laghave is offline Offline
Newbie Poster

Re: unzip, date, etc not available from scripts

 
0
  #4
Mar 19th, 2009
I tried both suggestions but it does not seem to work. Any idea what is happening? it works when I run the script from command line.

./init.VTd.nik: ./init.VTd.nik: 18: which: not found
./init.VTd.nik: ./init.VTd.nik: 20: /usr/bin/unzip: not found
./init.VTd.nik: ./init.VTd.nik: 47: make: not found
/u0/n/nikhill/alina/./Main_new: /u0/n/nikhill/alina/./Main_new: 176: date: not found

I am calling a script called Main_new which inturn calls the script init.VTd.nik and I seem to have this problem in both the scripts.
Please suggest something.

Thanks,
Nikhil
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,639
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 283
Moderator
masijade's Avatar
masijade masijade is offline Offline
Posting Maven

Re: unzip, date, etc not available from scripts

 
0
  #5
Mar 19th, 2009
That is not the full path to the command. I can guarantee that "." is not what you think it is. Use the full path whether setting the Path or using the full path in the command.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 11
Reputation: nikhil.laghave is an unknown quantity at this point 
Solved Threads: 0
nikhil.laghave nikhil.laghave is offline Offline
Newbie Poster

Re: unzip, date, etc not available from scripts

 
0
  #6
Mar 19th, 2009
Hello,
this is how I am making the call from the fortran routine:

Shell Scripting Syntax (Toggle Plain Text)
  1. CALL system("$HOME/alina/Main_new")

Previously I was doing it this was:
Shell Scripting Syntax (Toggle Plain Text)
  1. CALL system("$HOME/alina/./Main_new")

The script does run but i have the same problems. Also inside the Main_new script, I call the other script as :
Shell Scripting Syntax (Toggle Plain Text)
  1. /${HOME}/alina/run_VT/init.VTd.nik
, again with same problems. The script does run and the cp and mv commands also work, but make, date etc do not run even with PATH or giving direct path as:
Shell Scripting Syntax (Toggle Plain Text)
  1. /usr/bin/date
Last edited by nikhil.laghave; Mar 19th, 2009 at 5:41 pm.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 92
Reputation: prushik is on a distinguished road 
Solved Threads: 4
prushik prushik is offline Offline
Junior Poster in Training

Re: unzip, date, etc not available from scripts

 
0
  #7
Mar 19th, 2009
date is normally in /bin/ instead of /usr/bin/
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,639
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 283
Moderator
masijade's Avatar
masijade masijade is offline Offline
Posting Maven

Re: unzip, date, etc not available from scripts

 
0
  #8
Mar 20th, 2009
Please describe "does not run".
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Shell Scripting Forum


Views: 757 | Replies: 7
Thread Tools Search this Thread



Tag cloud for Shell Scripting
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC