delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/07/27/18:25:40

X-Spam-Check-By: sourceware.org
Date: Thu, 27 Jul 2006 18:25:24 -0400 (EDT)
From: Igor Peshansky <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: "McGraw, Robert P." <rmcgraw AT purdue DOT edu>
cc: cygwin AT cygwin DOT com
Subject: Re: How to run a cygwin command from the window scheduler
In-Reply-To: <03D3B32F0D0D024791C1EE97D087E909079283A5@EXCH01.purdue.lcl>
Message-ID: <Pine.GSO.4.63.0607271812360.1323@access1.cims.nyu.edu>
References: <03D3B32F0D0D024791C1EE97D087E909079283A5 AT EXCH01 DOT purdue DOT lcl>
MIME-Version: 1.0
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
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

On Thu, 27 Jul 2006, McGraw, Robert P. wrote:

> I need to schedule a job and it is not worth installing cron on our W2K3
> hosts for just for this one backup application.
>
> I have a name.sh script that if I run in a bash window it runs fine.
>
> In a W2K3 command prompt window I have tried
>
> 	C:\cygwin\usr\bin\bash.exe -c "\local\adminscripts\name.sh"
        ^^^^^^^^^^^^^^^^^^^^^^^[1]    ^^^^^^^^^^^^^^^^^^^^^^^^^^[2]

First off, if [1] works, something's seriously wrong with your system.
c:\cygwin\usr\bin should be empty, and all of the executables you find in
/usr/bin under Cygwin (notably bash) should be in c:\cygwin\bin.

Secondly, the way you specified the path ([2] above) is not going to work
in bash.  You really want to specify a POSIX path to your script.

> And I get
>
> 	bash-3.15$

Oh, really?  Assuming the above is not a typo, you're not running the
Cygwin bash.  The latest version that comes with Cygwin is 3.1, which uses
"bash-3.1$" as its default prompt.  In fact, that's the latest official
release of bash, too.

> If I type exit at the command prompt then the script runs bin at the
> command prompt mode.

Sorry, I can't quite parse the above.  Can you please describe the exact
steps you've taken to run the script?  Perhaps even with a small
self-contained script example?

> So the question is how do you start a unix shell script from the window
> command prompt.

The usual way (that would also replicate the environment you have in your
shell) is 'c:\cygwin\bin\bash.exe -l -c "/path/to/script.sh"'.  However,
you might want to also make sure that your PATH is set up correctly,
especially if you plan to do this through the Windows scheduler.  Also
note that the Windows scheduler will run your script as the SYSTEM user,
not as the user you normally use to log in.
HTH,
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_	    pechtcha AT cs DOT nyu DOT edu | igor AT watson DOT ibm DOT com
ZZZzz /,`.-'`'    -.  ;-;;,_		Igor Peshansky, Ph.D. (name changed!)
     |,4-  ) )-,_. ,\ (  `'-'		old name: Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte."
"But no -- you are no fool; you call yourself a fool, there's proof enough in
that!" -- Rostand, "Cyrano de Bergerac"

--
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