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: How to run a cygwin command from the window scheduler


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@cs.nyu.edu | igor@watson.ibm.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/


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