Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Script files ??

0 views
Skip to first unread message

David Stanaway

unread,
Jan 24, 1998, 3:00:00 AM1/24/98
to

If you have a bit of time I would recomend having a look at the manual listings
for bash, and sh
man bash
man sh

This gives you some of the more advanced stuff that you can do in a unix shell
which you can't realy do in a batch file. An generally Unix scripts have
something called a shbang at the top which points to the shell that will
execute the script.

this must be on the first line of the script, and the first two characters are
#!

followed on the smae line straight after by the path to the shell.

Say you wanted to use the Bourne shell whic is always in /bin/sh on Unix
systems the first line of the script would look like this.

#!/bin/sh

The rest of the file is like a batch file but you can certainly do more things
like loops.

Now if you are seting environment variables, they only last for that shell
unless you export them, then they will be inherited by subshell. Not however
that the environment variables are not passed back up the call chain.

You can dot in scrpts, but that is probably for another day.

Have fun.


Z

unread,
Jan 25, 1998, 3:00:00 AM1/25/98
to

In <6af5eh$8jr$1...@nargun.cc.uq.edu.au>, "Mark Eaton (HeTTaR)" <het...@nospam.uq.net.au> writes:

ME>forive my ignorance but how do you make scipt files?? I thought
ME>it would be easily done such ie like batch files for dos but it doesn't
ME>seem to work for me :(

ME>Can any tell me how it is done ??

It *is* like writing batch files in DOS. What you've probably forgotten is
to set the executable flag on your resulting script file (remember Unix
doesn't depend on having .exe, .bat, etc., extension to know what it can
execute and what it can't).

So:

1. Make your script file with a text editor, as in DOS
2. Use chmod to set the executable bit ('chmod 755 <file>', or whatever)

E.g. If I want a script to say "G'day" to me, I run up my favourite text
editor and make a file called 'hello' (say) with:

echo G\'day, mate!

Save it, then run 'chmod 755 hello' to make the file globally readable
and executable, and writable only by yourself. Alternatively,
'chmod u+x hello' to make it executable only by yourself, retaining
whatever permission were on it before. Read the chmod man page for all
the possible permutations.

Otherwise, you may not have the current directory (.) in your path (DOS
assumes this, but Unix does not), in which case you'll have to run your
script with './hello' rather than 'hello'. (Or just add . to your path).

Hope this helps.

Nicholas Sheppard

-- Location: Brisbane, Australia | I think that God in creating Man
/ n...@modemss.brisnet.org.au | somewhat overestimated his ability.
/ http://modemss.brisnet.org.au/~nps |
-- ----> Cynicism & Negativity | - Oscar Wilde


Mark Eaton (HeTTaR)

unread,
Jan 26, 1998, 3:00:00 AM1/26/98
to

Ahhh I didn't know about setting the executable bit Thankyou very much :)

--
Mark Eaton
(HeTTaR)
het...@nospam.uq.net.au
# To reply please remove the nospam
Z wrote in message <88573557...@gateway1.brisnet.org.au>...

Marcelo Cantos

unread,
Jan 27, 1998, 3:00:00 AM1/27/98
to

n...@modemss.brisnet.org.au (Z) writes:

> E.g. If I want a script to say "G'day" to me, I run up my favourite
> text editor and make a file called 'hello' (say) with:
>
> echo G\'day, mate!

Or preferably:

echo "G'day, mate! :-)"


Cheers,
Marcelo

0 new messages