delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/04/07/09:18:09

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
Subject: RE: Getting started with bash
Date: Mon, 7 Apr 2008 09:17:23 -0400
Message-ID: <31DDB7BE4BF41D4888D41709C476B6570929AD89@NIHCESMLBX5.nih.gov>
In-Reply-To: <f60fe000804070520q53519fb6x8ebd1c033fc46b7@mail.gmail.com>
References: <D9C5C745FD957899B39D7759 AT 192 DOT 168 DOT 1 DOT 20> <f60fe000804070520q53519fb6x8ebd1c033fc46b7 AT mail DOT gmail DOT com>
From: "Buchbinder, Barry (NIH/NIAID) [E]" <BBuchbinder AT niaid DOT nih DOT gov>
To: <cygwin AT cygwin DOT com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT 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
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id m37DI8Ll001307

Mark J. Reed wrote on Monday, April 07, 2008 8:21 AM:

> You hit the nail on the head with the environment vars question. 
> Bash tries to do the minimum amount of work possible when invoked
> non-interactively, on the assumption - almost universally true in
> *NIX - that it is being invoked by a process (usually another shell)
> that has its environment all set up already.  So when that's not the
> case, you need to tell bash so by adding the "-l" or "--login"
> option, so it will go out and read login-oriented startup files
> ([bash_]profile)  to set up its own environment.      
> 
> On 4/7/08, Joel M. Baldwin <qumqats AT outel DOT org> wrote:
>> 
>> --On Monday, April 07, 2008 10:25 AM +0200 Michael Holm
>> <hollo AT hollo DOT dk> wrote:
>> 
>>> Hi,
>>> 
>>> I have read a lot of documents, but i really cant get this issue
>>> solved :( All i want is to be able to execute bash scripts from a
>>> windows desktop.. what i do now is..
>>> 
>>> 
>>> a batch script:
>>> c:\cygwin\bin\bash c:\cygwin\example.sh
>>> 
>>> this is my bash script.
>>> 
>>> example.sh
>>> ls -l
>>> 
>>> but i get the following output:
>>> command not found.
>>> 
>>> i hope that someone can give me a hit... all i have done is:
>>> install cygwin, made my batch script.. and made my bash script.. do
>>> i need to set any environment vars or something?
>>> 
>>> mvh
>>> Michael Holm
>> 
>> Add the -l option to bash.
>> i.e. "man bash" for an explanation
>> 
>> This makes it a login shell which must cause the PATH variable to be
>> set. 

You might also want to us "-c", e.g.,
	bash -lc script
if you want bash to close automatically at the end of the script.

Also, I'm not sure that giving DOS/Windows paths will work, nor may paths using backslashes ("\"), which in unix-land are escape characters, for path separators (forward slashes ("/")).  So be sure that example.sh is in a directory that is in your path, or figure out what the full unix/cygwin path to it is, e.g.,
	bash -l /cygdrive/c/cygwin/example.sh
or
	bash -l /example.sh

- Barry

- Raw text -


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