[wplug] Linux Bat Files

Christopher DeMarco cmd at alephant.net
Thu Aug 25 12:41:36 EDT 2005


On Thu, Aug 25, 2005 at 09:26:41AM -0700, Mark A wrote:

> Jed marktest.bat
> (typed into file)  mkdir /var/www/docs/hobohound.org
> (saved the file, exited jed editor)

Wow... I can answer your question but - please don't take offense! -
this is such a low-level question you should probably head over to
your favorite bookseller and pick up a Bash Programming book!

In order to create a shell script (as they're called in UNIX; "bash"
is the name of the most-common shell), you need to do two things:

1.  Put this magic invocation at the top of the file:

#!/bin/sh

It *must* be the very first line, all by itself.


2.  Tell the OS that the file is executable:

chmod +x whatever_the_file_is_named

Now, you can execute the script:

./filename

Note the ``./'' at the front of the filename - that tells the system
to look in the current directory for the file.  It's good to get into
the habit of explicitly pointing to the file you want, even if it's
just in your current directory.

Another point of style - shell scripts are usually named with the
extension ".sh" for clarity.  ".bat" is a DOS artifact.


As for a shell programming book, there are probably many good
resources on the Internet, but as far as dead trees go, it's generally
accepted that O'Reilly makes the best books.  Seriously - they're
undisputed and are a class above anything else :)

Here are two favorites:

"Learning the Bash Shell - Third Edition"
http://www.oreilly.com/catalog/bash3/index.html
The best introduction to the bash shell and shell script programming


"UNIX Power Tools - Third Edition"
http://www.oreilly.com/catalog/upt3/index.html
A *fantastic* book - teaches you *MAGIC*.  


And no, I don't work for ORA :)


-- 
Christopher DeMarco <cmd at alephant.net>
Alephant Systems (http://alephant.net)
PGP public key at http://pgp.alephant.net
+1 412 708 9660
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.wplug.org/pipermail/wplug/attachments/20050825/7b0edf03/attachment.bin


More information about the wplug mailing list