Visit Our UNIX and Linux User Community


where to put shell scripts?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers where to put shell scripts?
# 1  
Old 07-16-2001
Question where to put shell scripts?

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????
# 2  
Old 07-16-2001
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  
Old 07-16-2001
Lightbulb

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.

Smilie
# 4  
Old 07-16-2001
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  
Old 07-16-2001
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  
Old 07-17-2001
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  
Old 07-17-2001
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 ...
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #2
Difficulty: Easy
Unix was invented by Steve Jobs of Apple Computer.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script variable $1 used with put command

I have the following script used, i am new to shell scripting. tryign to understand. in the put $BASE_FOLDER/$base_name holds which path. What does it mean by $1 second path in put command is it constructing this path: /user/hive/warehouse/stage.db/$1 what is $1 holding in above path. ... (2 Replies)
Discussion started by: cplusplus1
2 Replies

2. What is on Your Mind?

Fun things to put in comments in scripts?

Approaching the end of my portion of some STIG/DOD compliance automation and I was challenged by a co-worker to include a story in my code. There are blocks of code that need to be kept the way they are for GIT/Gerrit and then compliance, but otherwise I changed out all the comments into a... (2 Replies)
Discussion started by: Vryali
2 Replies

3. Shell Programming and Scripting

how to put data using shell script to a excel file

Hi, Can any one tell me how to put data using shell script to a excel file from text file to other columns of excel file,leaving first column unaffected i.e it should not overwrite data in first column. Say my text file data is: 15-dec-2008 15-dec-2009 16-dec-2008 16-dec-2009 say my first... (1 Reply)
Discussion started by: siri_886
1 Replies

4. Shell Programming and Scripting

New to Shell scripts and where do you put them

Hey all, I'm trying to setup an external XML feed for my site and I've received a script to make it all possible. This script places the feed in the MySQL datbasa and can remove the previous feed. Because I am new to this I would like to ask a simple question. Could somebody tell me where do I... (3 Replies)
Discussion started by: chrisdegrote
3 Replies

5. Shell Programming and Scripting

calling 'n' number of shell scripts based on dependency in one shell script.

Hello gurus, I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script. i m looking for something like this call 3.1; If 3.1 = "complete" then call 3.2; if 3.2 = ''COMPlete" then call 3.3; else exit The... (1 Reply)
Discussion started by: shashi369
1 Replies

6. Shell Programming and Scripting

read a file in shell and put result in a line

Hi All, I have a to read a file and put the result in one line. The i am reading from contain the data like below. 1 signifies the beging of the new line. (6 Replies)
Discussion started by: lottiem
6 Replies

7. Shell Programming and Scripting

Need to put a breakpoint in gdb using bash shell

I want a way to put a break point in gdb by runing a shell script. Actualy I wanted to do certain automisation of a long manual process, which includes starting of a process in background and then taking the process ID of that process and then attach the gdb to that process ID. Then finaly... (4 Replies)
Discussion started by: kapilkumawat
4 Replies

8. Shell Programming and Scripting

put a shell in for statement

I'm a newbie here, today I've got a problem. Here's the shell: b.sh #!/bin/bash rm -rf $1 a.sh #!/bin/bash for file in '/root/Desktop/test/*' do echo $file sh ./b.sh $file done ls /root/Desktop/test When I sh a.sh, the result is : (2 Replies)
Discussion started by: very.very.sorry
2 Replies

9. UNIX for Dummies Questions & Answers

place to put statup scripts?

I have written a script to start websphere server, I dont know where to put the file in the OS . please put me the place to put the starup scripts in linux, solaris and AIX? (2 Replies)
Discussion started by: jayaramanit
2 Replies

10. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

Featured Tech Videos