Script 101 (for DUMMIES)


Forum: Other Help Topics
Topic: Script 101 (for DUMMIES)
started by: JPsDad

Posted by JPsDad on Jan. 11 2008,01:16
In looking for answers to various howto questions, I see answers that say: i wrote a script
#!/bin/sh
..... or

Code Sample or


compiled for DSL kernel 2.4.31 - DSL ver2.0 up
               INSTRUCTIONS
## Install the driver. In EmelFM select ipw2200-k2.4.31.dsl and press "MYDSL"
## or the manual way - open an xterminal
sudo /etc/init.d/mydsl-install/<mylocation>/ipw2200-k2.4.31.dsl
## first we need to become superuser
sudo su
## now we need to run "depmod"  which is no problem with a HD install
## but difficult with the liveCD (and frugal) because much of the filesystem is read-only.
## so for a liveCD we need to make certain files writeable
## by running /home/dsl/depmodscript.sh  which is provided in this package.
## So run this next command only for liveCD  not HDinstalls
/home/dsl/depmodscript.sh
## map our new driver modules
depmod
## Now load the driver
modprobe ipw2200
## if no error messages  this should create a network interface  eth0 (or eth1  etc)
## you can check this by running "ifconfig -a"
...
I don't have any confidence in my attempts to follow these helpful responses. Where do I find the DSL for DUMMIES Manual so that I can RTFM and know what it told me to do??

Posted by mikshaw on Jan. 11 2008,02:00
#!/bin/sh as a first line tells an executable script to use /bin/sh as the interpreter for that script. If the script is already being run by sh (such as using the command "sh scriptname" or sourcing the script from another sh script), that line is not needed. If the file is not set with executable permissions (example: 755), that line means nothing and must be run specifically with the sh command or by sourcing into another sh script.

The other hash marks (#) are simply comments. They designate lines that are ignored by the interpreter and used for the education of the user...often they help the user understand what the script is doing or to modify the script for unique conditions. In this case I would guess the double hash marks were used simply to create an obvious separation between the comments and the actual commands used.

Take a look at the documentation at tldp.org. There is one particular piece that is specifically for the bash newbie:
< http://www.tldp.org/LDP/Bash-Beginners-Guide/html/index.html >

Posted by ^thehatsrule^ on Jan. 11 2008,07:30
If you really want to be specific, anything after #'s (on the same line) are designated as comments.
In essence, anything you enter in the command prompt can be saved into a script and executed as mikshaw described.

fyi, you can use the "[ code ]" (without spaces) tags in the forum.

Posted by WDef on Jan. 11 2008,08:40
Google will find many "introduction to bash scripting" type tutorials.  A search of this forum from the beginning will find a few good links.  That's how most of us started.  

A script is just a way of stringing together commands in a file.  Bash is the default scripting language on most linux systems.  Just a little knowledge of bash will greatly help your journey into linux.

Since dsl is a minimalist distro without as much in the way of soft landings as provided by the bigger distros, you will get the most out of it if you treat linux as a self-education exercise and make use of the wonderful resources provided by your forum search button and Google or your favorite search engine.

Posted by mikshaw on Jan. 11 2008,15:34
A very useful thing someone pointed out to me a while ago, when using Google for linux-specific queries it is often best to go to google.com/linux rather than just google.com
Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.