www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/08/28/16:26:28

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00
X-Spam-Check-By: sourceware.org
Message-ID: <4A983D66.7000009@bopp.net>
Date: Fri, 28 Aug 2009 15:26:14 -0500
From: Jeremy Bopp <jeremy AT bopp DOT net>
User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Automating a Cygwin Script From Windows
References: <25196125 DOT post AT talk DOT nabble DOT com>
In-Reply-To: <25196125.post@talk.nabble.com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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/script.sh

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/script.sh

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\script.sh 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.

-Jeremy

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019