![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| making a archive script | jimmyc | Shell Programming and Scripting | 1 | 09-15-2007 05:02 AM |
| making script | shary | Shell Programming and Scripting | 2 | 06-03-2007 05:16 PM |
| Need help making a script | npereira | Shell Programming and Scripting | 2 | 01-06-2007 01:14 PM |
| Making flags for my script | rcunn87 | Shell Programming and Scripting | 6 | 06-29-2006 11:23 AM |
| Help with making a parameter check script. | GCTEII | Shell Programming and Scripting | 2 | 03-07-2006 03:30 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Making a script exectuable
Hi, I'm pretty new to Unix and I just have a question concerning making a script executable without putting the "sh" command before it. In case it makes the difference I am on an Apple computer using the Terminal. Anyway here is the little test code I wrote followed by the commands I took to try to make it executable on its own.
Script #! /bin/sh # comments echo "blah" heh that's it, it works when I do enter sh Script now then the code I tried to use to execute it chmod u+x Script pwd ; echo $PATH and though no errors came up, it didn't work. So any insight would be really appreciated. Thanks. |
|
||||
|
well perhaps I'm just confused and expecting a greater return than possible. I expected after running the chmod I would be able to run the script (by typing the script name or ./script) from anyplace as I would other commands such as ls or mv, however at the moment all I can do is run the script through placing it, ie ./folder/folder/folder/script, which seems terribly inconvenient, maybe you can help just by clearing this confusion up for me.
|
|
||||
|
Hi,
Your question is not that clear ... Can u make it more elaborate ... Anyway I am writing this based on whatever I cud understand from the qn. chmod just sets the permissions for a file or directory .... If we need to execute the script, we have to do it explicitly ... either as "sh scriptname" or just "scriptname" ... and the absolute or relative path too if u r not running the script from the directory where the script is kept .... If your concern is that you have a script somewhere and u want to execute it from any other directory without taking the pain of giving the entire path and running each time ... can try this .... Edit your .profile file in your home directory ... and put an alias for this script .. runfromanywhere=/dir1/dir2/dir3/scriptname now u can just give runfromanywhere and execute ur script from anywhere ... hope i answered ur qn .. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|