![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Code Understand ? | varungupta | UNIX for Advanced & Expert Users | 2 | 05-02-2008 04:34 PM |
| Not able to understand what's do the statement | div_Neev | Shell Programming and Scripting | 1 | 02-20-2008 02:46 AM |
| Can't understand sar command | shaan_dmp | UNIX for Dummies Questions & Answers | 1 | 10-23-2007 04:04 AM |
| can't understand | BoyArcher | UNIX for Dummies Questions & Answers | 5 | 03-14-2006 06:36 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
can't understand this at all.
Ok, i've been trying to write some shell scripts. nothing challenging, but just automating
All of the tutorials i read say to start the file with #!/bin/bash or whatever your path to bash is. So i do it, and all of my scripts error out saying ./nameofscript:command not found when i remove the line completely the script seems to run ok. Why?? I understand the easy answer is to say "so just leave the line out" but I really would like to understand why it's happening. thanks, chris |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
First, read this: What does "#! /usr/bin/ksh" mean?
And then you need to figure out where bash is, if you have it at all. What OS are you using? Run the command "uname -a" and post the results so we know. "echo $SHELL" will probably tell you what shell you are using. Also try: which bash which ksh |
|
#3
|
|||
|
|||
|
thanks for that link. apparently I am about 50 steps ahead of myself
uname -a result Code:
FreeBSD PCBSD.localhost 6.1-RELEASE-p2 FreeBSD 6.1-RELEASE-p2 #1: Thu Jul 6 11:31:02 PDT 2006 root@PCBSD.localhost:/usr/obj/usr/src/sys/PCBSDv1.2 i386 Code:
/bin/csh Code:
PCBSD# which bash /usr/local/bin/bash PCBSD# which ksh ksh: Command not found. chris |
|
#4
|
||||
|
||||
|
So you need to use:
#! /usr/local/bin/bash as the first line of a bash script. |
|
#5
|
|||
|
|||
|
by the way, i suspect the reason your script runs fine without that line has something to do with it running using *your* shell. As above, it's much more sensible to specify the path to a command interpreter explicitly, since then you can specify which command interpreter to use in each script (for example, if you have different scripts that use different command interpreters). Depending on how your system's set up, you'd usually have to type "sh ./nameofscript" or something similar to run a script using an interpreter other than the one specified.
|
|||
| Google The UNIX and Linux Forums |