delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/03/14/14:11:14

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-0.5 required=5.0 tests=AWL,BAYES_50
X-Spam-Check-By: sourceware.org
Message-ID: <4D7E5A1D.5030702@bopp.net>
Date: Mon, 14 Mar 2011 13:10:37 -0500
From: Jeremy Bopp <jeremy AT bopp DOT net>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Autostart Cygwin on Windows boot and run a cygwin command
References: <31144428 DOT post AT talk DOT nabble DOT com>
In-Reply-To: <31144428.post@talk.nabble.com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.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

On 3/14/2011 09:07, PeterSmith wrote:
> 
> Sometimes my Windows server reboots at night to install new updates. Then the
> next day I find out that my cygwin instance has been stopped.
> 
> What I want is on Windows start, also run Cygwin AND run a specific command.
> 
> so, step 1: Right now I have a cygwin.bat to start cygwin:
> 
> @echo off
> C:
> chdir C:\cygwin\bin
> bash --login -i
> 
> step 2 is to enter the command in the command windows that appears after
> running cygwin.bat:
> 
> cd /cygdrive/e/solr/apache-solr-4.0-2010-10-12_08-05-48/example/;java
> -Dsolr.solr.home="./example-DIH/solr/" -jar start.jar
> 
> But this command is what I want to have called automatically when i run
> cygwin.bat
> 
> How can I combine step 1 and step 2 into a single bat file which I can run
> on Windows start?

While not 100% clear, I'm going to assume from your description that you
actually want this to run when you log in rather than when the machine
boots up.  It also looks like you know how to handle that part yourself.
 Ask about setting up a service if you would like this to run
independently of whether or not you ever log into the machine though.

> I tried this code:
> @echo off
> C:
> chdir C:\cygwin\bin
> bash -c cd
> /cygdrive/e/solr/apache-solr-4.0-2010-10-12_08-05-48/example/;java
> -Dsolr.solr.home="./example-DIH/solr/" -jar start.jar
> 
> But that doesnt work...

You need to help us help you here.  Simply saying that something doesn't
work without including any further details about what you see or error
messages you receive forces us to guess about the problem.

My guess about your problem is that your bash command is flawed.  The -c
option takes a single string that will be run as a command, and since
your command has spaces in it, you need to quote it.  Otherwise, the
command will be split on those spaces which will lead to erroneous
arguments for bash.  Because your command also has quotes, you'll need
to escape those with backslashes if you absolutely must keep them.
Maybe something like this will work for you:

bash -c "cd
/cygdrive/e/solr/apache-solr-4.0-2010-10-12_08-05-48/example/;java
-Dsolr.solr.home=\"./example-DIH/solr/\" -jar start.jar

If you still have problems, please provide more details. :-)

-Jeremy

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019