Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Nov 1997 01:15:37 +0100 (MEZ)
From:      Robert Eckardt <roberte@MEP.Ruhr-Uni-Bochum.de>
To:        gpavelcak@philos.umass.edu (Greg Pavelcak)
Cc:        roberte@MEP.Ruhr-Uni-Bochum.de, questions@FreeBSD.ORG, hey@tuns.ca
Subject:   Re: Batch files and #!/bin/shell
Message-ID:  <199711200015.BAA01835@ghost.mep.ruhr-uni-bochum.de>
In-Reply-To: <XFMail.971119165054.gpavelcak@philos.umass.edu> from Greg Pavelcak at "Nov 19, 97 04:42:17 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
It was Greg Pavelcak who wrote:
> 
> On 19-Nov-97 Robert Eckardt wrote:
> >read the corresponding man page and enter in a text file as the
> >very first line `#!/bin/YourShell' (assuming YourShell is in /bin)
> >followed by your batch commands.
> >Your batch commands can be any commands you enter on the commandline
> >plus some statements for flow control.
> >
> >Make the text file executable (chmod +x YourFile) and call
> I was just wondering what the !#/bin/yourshell does. I have written
> executable scripts without the shell specification and they have
> worked. For example to get my mail and news:
> 
> 
> 
> /usr/local/bin/fetchmail;
> /usr/local/bin/suck news.oit.umass.edu -dd /usr/gp -c -br
> /var/mail/gpbr;
> cat /var/mail/gpbr >>  /var/mail/gp;
> /usr/gp/bin/news2mail /var/mail/gp;
> rm /var/mail/gpbr
> 
> Am I playing with fire by not having the right first line. I execute
> the above script several times a day and run it from cron at night.

No danger of fire, as long as your first line doesn't start with #!. :-)

But try e.g.
8<---------------------------------
setenv ABC "Hello world."
echo $ABC
8<---------------------------------

This will give you `setenv: not found',
since it's a csh-specific command.
(Thus 
   #!/bin/csh
   setenv ABC "Hello world."
   echo $ABC
will work.)


Generally, the program (shell or s.th. else (e.g. awk)) after #! will
be started and fed with the contents of the file on stdin.


Robert

-- 
Robert Eckardt                \\ FreeBSD -- solutions for a large universe.(tm)
RobertE@MEP.Ruhr-Uni-Bochum.de \\       What do you want to boot tomorrow ?(tm)
http://WWW.MEP.Ruhr-Uni-Bochum.de/~roberte
For PGP-key finger roberte@gluon.MEP.Ruhr-Uni-Bochum.de



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199711200015.BAA01835>