![]() |
|
|
|
|
|||||||
| 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 |
| Shell Scripts | kwliew999 | AIX | 7 | 06-12-2007 05:06 PM |
| Using #! /bin/sh in Shell scripts | sumesh.abraham | Shell Programming and Scripting | 4 | 12-01-2006 03:29 AM |
| Help With Shell Scripts | ragha81 | Shell Programming and Scripting | 6 | 08-18-2006 05:57 PM |
| Need Help With Shell scripts | holler1 | Shell Programming and Scripting | 2 | 07-30-2006 11:43 PM |
| Difference between writing Unix Shell script and AIX Shell Scripts | haroonec | AIX | 0 | 04-11-2006 11:27 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
This could be a really dumb question, but for a newbie trying to learn, some help would be appreciated. When you write a shell script, what extension should it have, and more importantly, where do you put it????
|
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Shell scripts can have any extension that you want. I usually use .sh extension, but it's not a rule. The only things you must consider are:
- remember to put #/bin/"shell" in the beginning of your scripts - give appropriate execution permission to the script. I recomend you to create a standard for your shell scripts, like I did putting .sh as an extension for the scripts. About the place where you put them, you decide, but remember always to create a stantard for you, it can save you in critical hours. HTT |
|
#3
|
|||
|
|||
|
should be #!/bin/whateverSell
(i.e.#!/bin/sh ) My personal opion if this shell is for admin. purpose, I put it on /usr/bin, /usr/sbin or something defined on path. To check it, type "echo $PATH" or "env" if the shell is for personal use, I put it on my home dir.
__________________
:rolleyes: |
|
#4
|
|||
|
|||
|
As far as where to put the script....
Anywhere you like as long as the directory where the script resides is on the path echo $PATH to view the search path for executables. To add your directory to the path PATH=$PATH;your_dir (this is typically done in your .profile or ENV file (.kshrc or whatever) Assuming you're running korn shell |
|
#5
|
||||
|
||||
|
Remember that some day you might need to complete upgrade your OS and OS distribution.
In that case you are better off to keep the original source distribution clean and to put all your own stuff in: /usr/local/bin or /usr/local/sbin It is also a good idea to create a distinct disk partition for /usr/local or to go as far as to have an entire /usr/local hard disk (that is what I do): /usr/local/bin /usr/local/sbin /usr/local/apache/bin /usr/local/mysql/bin /usr/local/src .......... When you keep the applications and custom stuff out of the way of the standard OS stuff, it makes your life much easier when you have to upgrade; move to bigger disks; insall a new OS, etc. |
|
#6
|
|||
|
|||
|
Hi
Regarding a shell script's extension, it can have any extension and it's location depends on how do you want to use it. For e.g if you are starting with writing scripts then you can make a script (not specific can be of any name) in your home directory and then run it from there. Also ther are some scripts which bring up the database or the javawebserver. now since in some organisations these tasks needs to be automated, system admins usually place these scripts where the other system startup or runlevel scripts are placed.
Basically you need to place your scripts depending on how you are using them or what they are supposed to do or what login specific variables do they use. Hope this helps |
|
#7
|
|||
|
|||
|
Like all the others told you there is now restriction from the system on how to name shell-skripts or where to put them ...
but there are two things which are worth to think about it: 1. name the script with the same extension like the shell is .. eg: #!/bin/sh .... skript.sh #!/bin/csh ... skript.csh #!/bin/ksh ... skript.ksh I saw in the last years that its easier to do it like this ... 2. skripts which points to an application could be stored in the application tree or in the home-dir of the application-user skripts for the system-administration /usr/local/sbin skripts for users or any other purpose in /usr/local/bin thats the way we were happy with in the last years ... |
|||
| Google The UNIX and Linux Forums |