X-Spam-Check-By: sourceware.org Content-class: urn:content-classes:message MIME-Version: 1.0 Subject: RE: How to run a cygwin command from the window scheduler Date: Fri, 28 Jul 2006 10:18:55 -0400 Content-Type: multipart/signed; boundary="----=_NextPart_000_026C_01C6B22F.3B39AB40"; protocol="application/x-pkcs7-signature"; micalg=SHA1 Message-ID: <03D3B32F0D0D024791C1EE97D087E9090792842E@EXCH01.purdue.lcl> In-Reply-To: From: "McGraw, Robert P." To: Cc: "Igor Peshansky" Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com ------=_NextPart_000_026C_01C6B22F.3B39AB40 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit > -----Original Message----- > From: Igor Peshansky [mailto:pechtcha AT cs DOT nyu DOT edu] > Sent: Thursday, July 27, 2006 6:25 PM > To: McGraw, Robert P. > Cc: cygwin AT cygwin DOT 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 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" ------=_NextPart_000_026C_01C6B22F.3B39AB40 Content-Type: application/x-pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" MIAGCSqGS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