noob question

Reply

Join Date: Sep 2008
Posts: 369
Reputation: tomtetlaw is an unknown quantity at this point 
Solved Threads: 4
tomtetlaw's Avatar
tomtetlaw tomtetlaw is offline Offline
Posting Whiz

noob question

 
0
  #1
Jan 26th, 2009
What is shell scripting?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: noob question

 
0
  #2
Jan 26th, 2009
When talking about "programming" people tend to think that all code is a "program", but this just isn't true. Languages like VB, and C/C++, require that you first take the code that you write, and convert it to machine code (compile). After that (often done in the same step) you then "link" your code together into a Program. Linking has to do with putting together required external code (libraries) that are required by your program. Anyway, getting off topic, "Programming" is compiled into machine code.

Scripting is a different animal. Scripting doesn't require (from a top level view, anyways) that the code you write be compiled. Now, obviously before any code can run on a system, it must first be converted, but the compilation and linking isn't done by the programmer in a script. You have a program (typically called an Interpreter) that runs the lines of the script, and essentially compiles them on the fly. So, as the script writer, all you have to do is make changes to your script, and run it. The only drawbacks to this, is that your code is always available for view by anyone (that's actually a plus if you ask me), and it's slower when running. Compiled programs are typically fast, and scripts are usually slow. I wouldn't write something like a video game (even if there are libraries for it) in a scripting language. I might do something not time critical in one though. That's the general difference between programming and scripting, and I guess helps to answer what a "script" is.

In *nix, you have a wide variety of interfaces, because the idea is that the user is in control of their environment, unlike an OS such as windows, where you pretty much have to deal with the same interfaces. The command line in windows/DOS will never change...the syntax, etc. In *nix you can choose your own interface for the command line...this interface is called a shell. The most popular (by far) interface is Bash (The Bourne Again Shell). Most (if not all) operating systems provide a way to "batch commands" into a single file. So that when you run this simple script, it does a sequence of command line commands, that are typically repetitious and a pain to type over and over. Don't underestimate its power however, thinking that it is stuck just with batched command line commands.... it has the power of if statements, and loops, for conditional branching and recursive behavior. Shell scripts are a very powerful tool, that are often overlooked.
Last edited by Comatose; Jan 26th, 2009 at 8:09 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 369
Reputation: tomtetlaw is an unknown quantity at this point 
Solved Threads: 4
tomtetlaw's Avatar
tomtetlaw tomtetlaw is offline Offline
Posting Whiz

Re: noob question

 
0
  #3
Jan 26th, 2009
thanks for the quick and in-depth reply, What kind of things have people have managed to do with shell scripting?

also, i know this might not be the right place to ask, but how do people become a moderator of the forums?
Last edited by tomtetlaw; Jan 26th, 2009 at 8:13 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: noob question

 
0
  #4
Jan 26th, 2009
That's a list there. People will be able to post answers to that question for ages..... a couple common uses of Shell Scripts have been things such as log file rotations (programs can generate files that detail what it did, or what occured, called a log, they get too big, and a company wants them archived, so they build a shell script to automatically copy the log, (or group of logs) compress them, and back them up, then clear/remove the originals). There have been shell scripts to download youtube video's to your hard-drive... heck, a lot of startup scripts (startx... a big one) is a shell script. Shell scripts that monitor zombie processes...etc, etc. It's a big list.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Shell Scripting Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC