Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Date: Wed, 8 Nov 2000 16:56:15 -0500 From: Christopher Faylor To: cygwin AT sources DOT redhat DOT com Cc: gruen DOT lab AT yale DOT edu Subject: Re: Problem Executing Scripts Message-ID: <20001108165615.B18345@redhat.com> Reply-To: cygwin AT sources DOT redhat DOT com Mail-Followup-To: cygwin AT sources DOT redhat DOT com, gruen DOT lab AT yale DOT edu References: <3A09F4CA DOT 9D4C85BC AT yale DOT edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.6i In-Reply-To: <3A09F4CA.9D4C85BC@yale.edu>; from gruen.lab@yale.edu on Wed, Nov 08, 2000 at 04:50:18PM -0800 On Wed, Nov 08, 2000 at 04:50:18PM -0800, Jeffrey Gruen wrote: >Recently, I downloaded Cygwin-b20 (cygwin-1.1.4.tar) for WindowsNT. Where did you get the impression that this was "Cygwin-b20"? This is Cygwin 1.1.4. It has nothing to do with B20. >It has been working just fine until today when we tried to write some >very simple scripts to run. Below is one such script that runs >beautifully on a dec alpha UNIX machine, but will not run in Cygwin for >NT: > >#this little script makes back-up of files in a directory >for file in * >do >cp $file $file.bak >done > >So far, we have discovered: >1. How to make the file executable in Cygwin (by adding .exe to the end, >since "chmod" does not seem to work very well) > >2. That the "*.exe" file must to be in the bin folder in order to run > >3. That bash crashes if we make the first line of the script "#!/bin/sh" > >(We even tried running: "echo '#!/bin/sh' > script.exe; ./script", but >this did not work either). > >Please help. How can a make a script file that runs flawlessly in UNIX >run in Cygwin, as well. The ability to write and execute small scripts >like this would save me much time! As you have discovered, Windows does not have an 'execute bit', so you cannot just put some commands in a file, do a 'chmod -x file' and then './file'. Well, actually you can. If you are using an NTFS filesystem, then setting the CYGWIN environment variable to 'ntsec' (do this prior to running any cygwin program) will allow you to set the executable bit. The "NT security" model allows you to use full UNIX permissions on your files. It only works on NT, though. The usual way to make your scripts executable is by adding a '#!/bin/sh' to the beginning of them. Don't give the scripts a '.exe' extension. That will cause Windows to try to execute them as Windows executables rather than scripts. To execute the file, it has to be located in a directory referenced by your PATH environment variable. The current directory "." is not located in your PATH by default. You'll have to add it if you want to execute files in your current directory without typing "./file". One esoteric way to give a script or a directory executable permission is to use the mount command: mount -x -b c:\cygwin\bin /bin # cygwin gives everything in /bin # the 'executable' bit mount -x -b c:\cygwin\bin\foo /bin/foo # cygwin gives /bin/foo the # executable bit Most of the above should be located in the Cygwin FAQ. I would suggest that you read this and the other documentation available at www.cygwin.com so that you don't have to "figure out" stuff in the future. cgf -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com