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



> -----Original Message-----
> From: Igor Peshansky [mailto:pechtcha@cs.nyu.edu]
> Sent: Thursday, July 27, 2006 6:25 PM
> To: McGraw, Robert P.
> Cc: cygwin@cygwin.com
> Subject: 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.
[McGraw, Robert P.] 
Humm I just ran the setup. I did a "ls -1 | wc" on both /bin and /usr/bin
and got the same number. I wonder if it is a link.
> 
> 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.
[McGraw, Robert P.] 
Yes this was a typo should have been bash-3.1$
> 
> > 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?
[McGraw, Robert P.] 
Trying to get the email out as my wife calls saying she is downstairs ready
to take me home.

I have a script called test.sh in /local/adminscripts. /local is a directory
that I made. The script is 

	#! /bin/sh
	echo "HELLO WORLD"

in a W2K3 command prompt (DOS) window 

	C:\cywin\bin>     (which is the command prompt prompt)

I type the command

	c:\cygwin\bin\bash -c "/local/adminscripts/test.sh"

It returns

	bash-3.1$

and waiting for input. I then type exit and the script executes. The output
is like this:

bash-3.1$ exit
exit
HELLO WORLD

C:\cywin\bin>   (which is the command prompt prompt)



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

Attachment: smime.p7s
Description: S/MIME cryptographic signature


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