From owner-freebsd-questions Wed Nov 19 16:16:00 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id QAA16126 for questions-outgoing; Wed, 19 Nov 1997 16:16:00 -0800 (PST) (envelope-from owner-freebsd-questions) Received: from ghost.mep.ruhr-uni-bochum.de (ghost.mep.ruhr-uni-bochum.de [134.147.6.33]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id QAA16117 for ; Wed, 19 Nov 1997 16:15:51 -0800 (PST) (envelope-from roberte@ghost.mep.ruhr-uni-bochum.de) Received: (from roberte@localhost) by ghost.mep.ruhr-uni-bochum.de (8.8.5/8.8.4) id BAA01835; Thu, 20 Nov 1997 01:15:37 +0100 (MEZ) From: Robert Eckardt Message-Id: <199711200015.BAA01835@ghost.mep.ruhr-uni-bochum.de> Subject: Re: Batch files and #!/bin/shell In-Reply-To: from Greg Pavelcak at "Nov 19, 97 04:42:17 pm" To: gpavelcak@philos.umass.edu (Greg Pavelcak) Date: Thu, 20 Nov 1997 01:15:37 +0100 (MEZ) Cc: roberte@MEP.Ruhr-Uni-Bochum.de, questions@FreeBSD.ORG, hey@tuns.ca X-Mailer: ELM [version 2.4ME+ PL31H (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk 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