[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Can't get scripts to work



matheson@mail1.facile.com (Cameron Matheson) wrote:
>I can't get any of my scripts to work.  I'm just trying to start simple, by
>making a script to delete all my FreeCiv save files.  I use 'vi' and type
>the following:
>
>           # !/bin/sh
>           rm civgame*
>           clear
>           pwd
>           ls -l
>
>Then I type "chmod u+x removeCiv.sh" to add execute permission to myself,
>but when i type "removeCiv.sh" at the prompt i get the error "bash:
>removeCiv.sh: command not found"
>
>How do I get my scripts to work?

As well as what's already been mentioned, you should use '#! /bin/sh',
not '# !/bin/sh'; the difference is significant to the kernel, which
uses the shebang (#!) to start up the "executable interpreter" mechanism
for scripts. '#!/bin/sh' will also work on Linux, but I believe other
Unices (BSD?) use '#! /' as the executable interpreter marker, so
'#! /bin/sh' is safer.

It happens that your script would work in this case, but not if you
moved to some other language like Perl. (Why does this work, by the way?
Is /bin/sh the default interpreter?)

-- 
Colin Watson                                           [cjw44@cam.ac.uk]


Reply to: