public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* How to run a cygwin command from the window scheduler
@ 2006-07-27 22:11 McGraw, Robert P.
  2006-07-27 22:32 ` Igor Peshansky
  0 siblings, 1 reply; 5+ messages in thread
From: McGraw, Robert P. @ 2006-07-27 22:11 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 901 bytes --]

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"

And I get 

	bash-3.15$

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

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

Robert



_____________________________________________________________________
Robert P. McGraw, Jr.
Manager, Computer System                 EMAIL: rmcgraw@purdue.edu
Purdue University                         ROOM: MATH-807
Department of Mathematics                PHONE: (765) 494-6055
150 N. University Street                   FAX: (419) 821-0540
West Lafayette, IN 47907-2067            



[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 3051 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to run a cygwin command from the window scheduler
  2006-07-27 22:11 How to run a cygwin command from the window scheduler McGraw, Robert P.
@ 2006-07-27 22:32 ` Igor Peshansky
  2006-07-28 14:32   ` McGraw, Robert P.
  0 siblings, 1 reply; 5+ messages in thread
From: Igor Peshansky @ 2006-07-27 22:32 UTC (permalink / raw)
  To: McGraw, Robert P.; +Cc: cygwin

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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: How to run a cygwin command from the window scheduler
  2006-07-27 22:32 ` Igor Peshansky
@ 2006-07-28 14:32   ` McGraw, Robert P.
  2006-07-28 17:51     ` Igor Peshansky
  0 siblings, 1 reply; 5+ messages in thread
From: McGraw, Robert P. @ 2006-07-28 14:32 UTC (permalink / raw)
  To: cygwin; +Cc: Igor Peshansky

[-- Attachment #1: Type: text/plain, Size: 3523 bytes --]



> -----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 #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 3051 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: How to run a cygwin command from the window scheduler
  2006-07-28 14:32   ` McGraw, Robert P.
@ 2006-07-28 17:51     ` Igor Peshansky
  0 siblings, 0 replies; 5+ messages in thread
From: Igor Peshansky @ 2006-07-28 17:51 UTC (permalink / raw)
  To: McGraw, Robert P.; +Cc: cygwin

Please make sure your mailer respects the Reply-To: header -- I set it for
a reason.  There was no need to Cc: me -- I read the list.

On Fri, 28 Jul 2006, McGraw, Robert P. wrote:

> > -----Original Message-----
> > From: Igor Peshansky [mailto:pechtcha@XX.XXX.XXX]
> > Sent: Thursday, July 27, 2006 6:25 PM
> > To: McGraw, Robert P.
> > Cc: cygwin@XXXXXX.XXX

<http://cygwin.com/acronyms/#PCYMTNQREAIYR>.  Thanks.

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

It's a mount.  Try "man mount" or read about mounts in the User's Guide
(<http://cygwin.com/cygwin-ug-net/using.html#mount-table>).

Which also means that /usr/bin != c:\cygwin\usr\bin, with all the obvious
consequences.

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

Umm, weird.  Sufficiently weird that we need to know more about your
installation to be able to help.  Please read and follow the Cygwin
problem reporting guidelines at <http://cygwin.com/problems.html>,
particularly the part about *attaching* the output of "cygcheck -svr".

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

The above also implies that your rc files may contain weirdness.  Please
also attach the contents of .bashrc and .bash_profile in your home
directory.
	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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: How to run a cygwin command from the window scheduler
@ 2006-07-29 14:23 Shaffer, Kenneth
  0 siblings, 0 replies; 5+ messages in thread
From: Shaffer, Kenneth @ 2006-07-29 14:23 UTC (permalink / raw)
  To: cygwin


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

Type "mount" instead from your DOS prompt while in the c:\cygwin\bin
directory.  If you see a mount point of "/" pointing to anywhere else
besides c:\cygwin, that could be part of your problem.

I recently had a mounting issue when upgrading from a very old cygwin,
b20 I think, and "umount -A" couldn't get rid of it, so I used regedit
to remove it.

The following is similar to what I use as a scheduled task:

    Run: C:\WINNT\system32\CMD.EXE /x /c start "Some title" /min
c:\cygwin\cygwin.bat cygwin_script arg1 arg2
    Start In: c:\cygwin     <-- must be a real disk drive and path
    Run as: domain\username

The cygwin.bat file:

    @echo off
    rem set HOME=c:\
    if "%DEF_PATH%"=="" set DEF_PATH=%PATH%
    set PATH=c:\cygwin\bin;%DEF_PATH%
    set myargs=%*
    if "%myargs%" == "" goto noarg
    rem echo %myargs%
    bash --rcfile %HOME%/.bashrc -i -c "%myargs%" 
    c:
    rem pause
    sleep 1
    goto exit
    :noarg

    rxvt -e /usr/bin/bash --login -i

    :exit
    exit

Ken Shaffer


     - - - - - Appended by Scientific Atlanta, a Cisco company - - - - -  This e-mail and any attachments may contain information which is confidential, proprietary, privileged or otherwise protected by law. The information is solely intended for the named addressee (or a person responsible for delivering it to the addressee). If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer.


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-07-29 13:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-27 22:11 How to run a cygwin command from the window scheduler McGraw, Robert P.
2006-07-27 22:32 ` Igor Peshansky
2006-07-28 14:32   ` McGraw, Robert P.
2006-07-28 17:51     ` Igor Peshansky
2006-07-29 14:23 Shaffer, Kenneth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).