LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-18-2003, 12:59 AM   #1
mymojo
Member
 
Registered: Oct 2003
Distribution: Slackware 9.1
Posts: 176

Rep: Reputation: 30
What is a Script? (I'm not man enough)


Could someone inform me, or point to a URL where it describes what a script actually is?

On Linux, is it just a C++ file compiled, or, just what is it? how do I make them/run them?

stuff like this doesn't help me much.
 
Old 10-18-2003, 01:06 AM   #2
Sometimes
Member
 
Registered: Oct 2003
Location: Richmond, VA
Distribution: Depends on the week...
Posts: 64

Rep: Reputation: 15
Well, not EXACTLY sure what you're asking but...

A script is a non-compiled program. That is the easiest way to describe it.

A script can be written in a thousand different languages/ways.

For example, this is a script I actually use:

--SNIP--

#!/usr/bin/bash

cat /proc/cpuinfo
uname
free -m
df -kf

--SNIP--

It just runs all four of those commands. The only complicated part is the first line: that just tells the kernel what the script is written for.

You can script in shells (bash, tcsh, etc) specific scripting languages (perl, javascript, php) and sometimes you can write scripts in languages that are normally compiled (there is functionality for C, java, others).

Hope that answers your question!
 
Old 10-18-2003, 01:09 AM   #3
Sometimes
Member
 
Registered: Oct 2003
Location: Richmond, VA
Distribution: Depends on the week...
Posts: 64

Rep: Reputation: 15
Realized I didn't answer your last question:

To run a script, you simply enter it into a file using whatever editor you prefer, and then make sure that file is set to be executable.

If you run a "ls -l" it will show you what flags are set for each file:
r - read
w - write
x - executable

You can use the "chmod" command to change these settings. Then you can run the script like any other program/command.
 
Old 10-18-2003, 01:14 AM   #4
Skyline
Senior Member
 
Registered: Jun 2003
Distribution: Debian/other
Posts: 2,104

Rep: Reputation: 45
A bash script in Linux is just a simple text file containing a list of "instructions" to be executed when run - you can create a bash script by openeing a text file and putting #!bin/bash as the first line then putting your "instructions" below it - make sure you make the file executable with chmod 755 filename, and make sure you put it in your PATH - you can run it with

bash filename
 
Old 10-18-2003, 01:17 AM   #5
misc
Senior Member
 
Registered: Apr 2003
Distribution: Red Hat + Fedora
Posts: 1,084

Rep: Reputation: 54
Generally, a script is a file which contains a sequence of commands or instructions to be executed. A script is passed on to an interpreter, a program that understands the instructions in the script file. The interpreter can be anything ranging from command-shells like /bin/bash to high-level programming languages like Perl or Python.

Many people know one form of scripts: MS-DOS batch (.bat) files.

On the contrary, files (such as C/C++ files), which are not interpreted but compiled and linked in order to build an executable program , are not referred to as scripts but source code.
 
Old 10-18-2003, 01:50 AM   #6
mymojo
Member
 
Registered: Oct 2003
Distribution: Slackware 9.1
Posts: 176

Original Poster
Rep: Reputation: 30
That all answers my question. Thanks
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
apropos, man -k, man -f? krishvij Linux - Newbie 5 06-06-2005 01:42 PM
man alsamixer not showing the man page nosaku Slackware 1 12-20-2004 08:52 AM
How to quit man (less) and keep man info on screen? peb Linux - Newbie 7 03-25-2004 10:02 PM
Different man? mikeshn Linux - General 1 08-22-2002 09:42 AM
Compiling packages on RH 7.1 causes man files to be named man.gz mmboam Linux - General 0 05-09-2001 06:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:26 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