LinuxQuestions.org
Help answer threads with 0 replies.
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 05-16-2006, 01:38 PM   #1
newbiesforever
Senior Member
 
Registered: Apr 2006
Location: Iowa
Distribution: Debian distro family
Posts: 2,373

Rep: Reputation: Disabled
how do I run a script?


If I have a multi-line script to run, how do I enter it at the command line--one line at a time, or all at once (by cutting and pasting)?
 
Old 05-16-2006, 01:48 PM   #2
meng
Member
 
Registered: Apr 2005
Location: Rochester, MN
Distribution: Ubuntu 7.04
Posts: 127

Rep: Reputation: 15
Not sure I understand the question. The whole point of a script is to automate a multi-step task. Can you elaborate on why would you type a script into the command-line? Then it might be clearer how to answer your question.
 
Old 05-16-2006, 02:47 PM   #3
newbiesforever
Senior Member
 
Registered: Apr 2006
Location: Iowa
Distribution: Debian distro family
Posts: 2,373

Original Poster
Rep: Reputation: Disabled
Someone gave me a script to detect my wireless network, but he didn't say what to do with it, so I would have typed it at the CL.
 
Old 05-16-2006, 02:55 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
A script goes into a file. To run it, set the execute permissions. In the CLI, type ./filename to run it (within its directory). From an arbitrary location, type the full path. From the GUI double-click.

A large percentage of Linux utilities are scripts. Open one with an editor to see how it is set up.

Last edited by pixellany; 05-16-2006 at 03:09 PM.
 
Old 05-16-2006, 02:56 PM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You could make the script executable and put it in your ~/bin/ directory. Then call the script by name.
 
Old 05-16-2006, 02:57 PM   #6
meng
Member
 
Registered: Apr 2005
Location: Rochester, MN
Distribution: Ubuntu 7.04
Posts: 127

Rep: Reputation: 15
Ok. Well if you're only ever going to use it once in your life, then you could enter it one command at a time on the CLI. An alternative is to enter several commands separated by &&, i.e.
<commandthefirst> && <commandthesecond> && ...

But if you think you might need to use it again in future, then you should definitely save the text as a file (usually with a .sh extension), then chmod +x <nameoffile>, then ./<nameoffile> to run the script.
 
  


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
'cannot stat' script in /etc/rc.d/, try to run script at startup quintan Linux - Software 1 11-21-2005 02:53 AM
Shell script to run pl/sql script. colly Linux - General 1 09-09-2004 06:49 AM
Script to run script in multiple directories... seabass55 Linux - General 5 07-06-2004 12:44 AM
on Network Up Script run? On Battery power run script? v2-ncl Linux - General 0 12-08-2003 09:34 AM
can't run a script script from icon in konqueror scottsteibel Linux - Software 1 08-02-2003 07:59 PM

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

All times are GMT -5. The time now is 05:42 AM.

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