delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/07/28/11:46:51

X-Spam-Check-By: sourceware.org
Date: Fri, 28 Jul 2006 11:45:51 -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: <03D3B32F0D0D024791C1EE97D087E9090792842E@EXCH01.purdue.lcl>
Message-ID: <Pine.GSO.4.63.0607281138580.9201@access1.cims.nyu.edu>
References: <03D3B32F0D0D024791C1EE97D087E9090792842E 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

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 AT XX DOT XXX DOT XXX]
> > Sent: Thursday, July 27, 2006 6:25 PM
> > To: McGraw, Robert P.
> > Cc: cygwin AT XXXXXX DOT 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 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