LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-11-2007, 08:28 AM   #1
jonette20
Member
 
Registered: Jul 2007
Location: Ohio
Distribution: Ubuntu 7.04
Posts: 65

Rep: Reputation: 15
Executing scripts


Hi,

I am not a programmer.
I have never written a script. I know there are tutorials on the subject and I have one bookmarked.
My biggest question about scripts is where do you put them?
Sometimes the documentation on Linux might say, just run this perl script, or insert my script, how is this done?

Thanks in advance
jonette20
 
Old 10-11-2007, 08:46 AM   #2
camorri
LQ 5k Club
 
Registered: Nov 2002
Location: Somewhere inside 9.9 million sq. km. Canada
Distribution: Slackware 15.0, current, slackware-arm-currnet
Posts: 6,215

Rep: Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849
Quote:
My biggest question about scripts is where do you put them?
Generally you want to put scripts, in your PATH. To find out what your PATH is set to in linux, open a konsole, and run the command 'echo $PATH' with out the quotes. This is what my system looks like, just as an example.

Code:
 echo $PATH
/usr/bin:/bin:/usr/local/bin:/usr/X11R6/bin/:/usr/games:/usr/java/jre1.6.0_01/bin:/usr/lib/qt3//bin:/home/cliff/bin:/usr/lib/qt3//bin
So If I created or copied a script I wanted to run, from the above a good place would be /usr/bin or /usr/local/bin.

The reason this will work, is because the PATH system variable is where the
system looks for executables, or commands when you type something in.

If you have a lot of your own scipts, I would suggest addign a directory, and then updating your PATH variable. In this way you keep scripts together
and separate from other binary files, just so you stay organized, and you,
the system admin knows where things are.

Quote:
Sometimes the documentation on Linux might say, just run this perl script, or insert my script, how is this done?
Perl scripts require Perl libs installed. Perl scripts are source, like commands that get fed through ( I think a perl interpreter ) and executed.

To run them, with the correct perl libs installed, just type the script name in a konsole. Of course the script permissions have to be set so your user, usually the owner, can execute them.

Hope this helps.
 
Old 10-11-2007, 07:11 PM   #3
Bernard Swiss
LQ Newbie
 
Registered: Sep 2007
Location: Just outside Vancouver, Canada
Distribution: Debian (for now)
Posts: 27

Rep: Reputation: 24
Some distributions make advance allowance for a ~/bin directory.

For example, in Debian the ~/.bash_profile file may have some lines in it like this:
Code:
# set PATH so it includes user's private bin if it exists
if [ -d ~/bin ] ; then
    PATH=~/bin:"${PATH}"
    fi
This means all you need to do is make a "bin" directory in your home directory ( user@localhost:~ $ mkdir bin )

Then you can run any scripts that can run with just your permissions right from your home enviroment.

###################################
PS:

For this to work, you need to make sure that your xterm or xterminal-emulator (eg. gnome-terminal) is configured to act as a login shell -- otherwise the xterm won't read-in the .bash_profile.

Another option, is to justrun the script as
~/bin/your_script,
or from the home directory with
./bin/your_script,
or from wherever with
~/bin ./your_script.

In fact, ./your_script will work in whatever directory you have the script in
(eg ~/test_directory )

Last edited by Bernard Swiss; 10-12-2007 at 12:06 AM.
 
Old 10-15-2007, 01:50 PM   #4
jonette20
Member
 
Registered: Jul 2007
Location: Ohio
Distribution: Ubuntu 7.04
Posts: 65

Original Poster
Rep: Reputation: 15
Hi,

Thanks alot. Both of the answers were very informative and helpful.

jonette20
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
executing Bash Scripts c4nk Linux - General 3 03-11-2007 04:52 PM
CGI Scripts not executing Mr_Oz Linux - Enterprise 7 04-18-2006 03:21 PM
Executing scripts upon login jungatheart Linux - Newbie 3 04-19-2004 06:06 PM
Executing Shell Scripts? l0f33t Linux - General 7 08-17-2003 03:36 PM
Executing shell scripts justinv Linux - General 6 01-26-2003 07:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration