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: Autostart Cygwin on Windows boot and run a cygwin command


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


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