delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/11/15/22:50:08

Message-ID: <437AAC5F.1091A631@dessent.net>
Date: Tue, 15 Nov 2005 19:49:51 -0800
From: Brian Dessent <brian AT dessent DOT net>
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Simple cygwin script doesn't work with Windows schedular/Command prompt
References: <92E67798C43ECE4691CCEE09662D26980A0ACFE2 AT scsmsx402 DOT amr DOT corp DOT intel DOT com>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
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

"Pandey, Sunil K" wrote:

> However when I try to launch the same script with windows scheduler via
> following command line it doesn't work.

That is because if you type "/tmp/test.csh" at the prompt, bash will ask
the system to execute the script and the #!/bin/csh line will be
honored.  It will also do this if you run it as "bash -c /tmp/test.csh",
since that is by definition what the -c flag means.

But if you just run "bash test.csh" (which is what you are doing in you
cronjob) then bash will read the file itself and try to execute each
line as if it were a command.  This will also happen if you type "source
test.csh" or ". test.csh".  And because you are using csh syntax, not
bourne shell syntax, you get unexpected results.

So what this all means is that if you want /bin/csh to execute your
script you need to invoke it as either "bash -c /tmp/test.csh" or "csh
/tmp/test.csh".

None of this has anything to do with Cygwin.  You will find the exact
same behavior on any *nix.

Brian

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

- Raw text -


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