This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Automating a Cygwin Script From Windows

jprice wrote:
> I need to run a cygwin script directly via windows, probably via dos prompt
> or some other comparable method. This method needs to be automated and
> kicked off in Windows at certain times, so executing Cygwin, then manually
> typing in the script to run in the Cygwin prompt is out of the question.
> I was hoping there would be some way to execute Cygwin and concurrently feed
> it a string of commands to execute upon opening, but unfortunately I have
> not had success with this. There seems to be lots of command line options
> for setting display options but nothing that would allow me to feed in a
> command.
> Is there any method to do this? Thanks for your time.

I think you might be getting the shortcut you use to start the Bash
shell confused with the emulation layer which is Cygwin.  If you have a
*Bash* script which you need to run, you can use the bash.exe program
installed as part of Cygwin to run it.

Assuming you installed Cygwin to the default location, you can run the
script as follows:

C:\cygwin\bin\bash.exe path/to/your/

The only other thing you may need to do is modify your PATH environment
variable so that any programs that script tries to run can be found.  In
that case you may want to do the following in your batch file or
whatever you're using to kick off the script:

set PATH=C:\cygwin\bin;%PATH%
bash path/to/your/

This will ensure that programs such as ls, mkdir, etc. are able to be
found by the script when used.

Please note that you should try to avoid using a Windows-style absolute
path such as C:\path\to\your\ when passing the path to
bash.exe.  It will probably work, but it could also cause confusing
issues.  Use forward slashes (/) instead of backslashes (\) and relative
paths rather than absolute to keep things simple.


Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]