LinuxQuestions.org
Register a domain and help support LQ
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, 09: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, 09:46 AM   #2
camorri
Senior Member
 
Registered: Nov 2002
Location: Somewhere inside 9.9 million sq. km. Canada
Distribution: Slackware 14.1
Posts: 4,868

Rep: Reputation: 434Reputation: 434Reputation: 434Reputation: 434Reputation: 434
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, 08:11 PM   #3
Bernard Swiss
LQ Newbie
 
Registered: Sep 2007
Location: Just outside Vancouver, Canada
Distribution: Debian (for now)
Posts: 25

Rep: Reputation: 15
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 01:06 AM.
 
Old 10-15-2007, 02: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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 05:52 PM
CGI Scripts not executing Mr_Oz Linux - Enterprise 7 04-18-2006 04:21 PM
Executing scripts upon login jungatheart Linux - Newbie 3 04-19-2004 07:06 PM
Executing Shell Scripts? l0f33t Linux - General 7 08-17-2003 04:36 PM
Executing shell scripts justinv Linux - General 6 01-26-2003 08:57 AM


All times are GMT -5. The time now is 07:50 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration