Autostart Cygwin on Windows boot and run a cygwin command

2011-03-14 Thread PeterSmith

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?

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

-- 
View this message in context: 
http://old.nabble.com/Autostart-Cygwin-on-Windows-boot-and-run-a-cygwin-command-tp31144428p31144428.html
Sent from the Cygwin list mailing list archive at Nabble.com.


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



Re: Autostart Cygwin on Windows boot and run a cygwin command

2011-03-14 Thread Jeremy Bopp
On 3/14/2011 13:10, Jeremy Bopp wrote:
 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

I forgot to append the trailing quote on the above command.  It should
be as follows:

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

-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



Re: Autostart Cygwin on Windows boot and run a cygwin command

2011-03-14 Thread Jeremy Bopp
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



Re: Autostart Cygwin on Windows boot and run a cygwin command

2011-03-14 Thread PeterSmith

First of: sorry for not providing all info.

I DO want to run this command as soon as my machine boots. My server
sometimes reboots at night after an update. So when Windows starts, in the
Startup Folder I will place a shortcut to the .bat file.

I the bat file I now have:
@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 

When I run this from the command prompt I get this error:

C:\start_cygwin.bat
bash: line 0: cd:
/cygdrive/e/solr/apache-solr-4.0-2010-10-12_08-05-48/example/: No such file
or directory
Unable to access jarfile start.jar
C:\cygwin\bin


Hopefully my problem is more clear now and you can further assist me :)





Jeremy Bopp-3 wrote:
 
 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
 
 
 

-- 
View this message in context: 
http://old.nabble.com/Autostart-Cygwin-on-Windows-boot-and-run-a-cygwin-command-tp31144428p31147099.html
Sent from the Cygwin list mailing list archive at Nabble.com.


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



Re: Autostart Cygwin on Windows boot and run a cygwin command

2011-03-14 Thread Jeremy Bopp
On 3/14/2011 13:25, PeterSmith wrote:

FYI, this list prefers bottom posting rather than top posting.
Reformatting... :-)

 Jeremy Bopp-3 wrote:
 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. :-)

 First of: sorry for not providing all info.

 I DO want to run this command as soon as my machine boots. My server
 sometimes reboots at night after an update. So when Windows starts, in the
 Startup Folder I will place a shortcut to the .bat file.

What Startup Folder are you talking about exactly?  I'm probably just
not aware of such a folder whose contents are executed by the system
upon boot up, but if you're talking about the folder for your user
account, that will only be run when you log in.  If your machine
automatically logs you in on boot up, you'll be fine in that case;
otherwise, you'll need to hook this up a bit differently.

You may want to look into the Registry:

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

I'm not sure if you can directly run a batch file there or if you'll
have to run cmd with the batch file as an argument.  Assuming this works
for you, the only problem then will likely be that this will run as the
Local System account rather than your user, which may or may not matter
to you.

 I the bat file I now have:
 @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

I forgot to include the final quote in my first reply.  Try again with a
quote at the end of that last line.

-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



Re: Autostart Cygwin on Windows boot and run a cygwin command

2011-03-14 Thread Jan Bruun Andersen
On Mar 14, 2011 3:07 PM, PeterSmith wrote:

 What I want is on Windows start, also run Cygwin AND run a specific command.

Why? Why bother with Cygwin? You are starting some Java program that I
assume will work just fine when started from a simple CMD-script.

@echo off
E:
cd solr\apache-solr-4.0-2010-10-12_08-05-48\example
java -Dsolr.solr.home=.\example-DIH\solr -jar start.jar

--
Jan Bruun Andersen

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



Re: Autostart Cygwin on Windows boot and run a cygwin command

2011-03-14 Thread PeterSmith



Jeremy Bopp-3 wrote:
 
 On 3/14/2011 13:25, PeterSmith wrote:
 
 FYI, this list prefers bottom posting rather than top posting.
 Reformatting... :-)
 
 Jeremy Bopp-3 wrote:
 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. :-)

 First of: sorry for not providing all info.

 I DO want to run this command as soon as my machine boots. My server
 sometimes reboots at night after an update. So when Windows starts, in
 the
 Startup Folder I will place a shortcut to the .bat file.
 
 What Startup Folder are you talking about exactly?  I'm probably just
 not aware of such a folder whose contents are executed by the system
 upon boot up, but if you're talking about the folder for your user
 account, that will only be run when you log in.  If your machine
 automatically logs you in on boot up, you'll be fine in that case;
 otherwise, you'll need to hook this up a bit differently.
 
 You may want to look into the Registry:
 
 HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
 
 I'm not sure if you can directly run a batch file there or if you'll
 have to run cmd with the batch file as an argument.  Assuming this works
 for you, the only problem then will likely be that this will run as the
 Local System account rather than your user, which may or may not matter
 to you.
 
 I the bat file I now have:
 @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
 
 I forgot to include the final quote in my first reply.  Try again with a
 quote at the end of that last line.
 
 -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
 
 
 

Ok, so for now lets focus on the contents of the .bat file. I'll have a look
at the startup of the bat later :)

I now have this:
@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 still gives me the exact same error:
C:\start_cygwin.bat
bash: line 0: cd:
/cygdrive/e/solr/apache-solr-4.0-2010-10-12_08-05-48/example/: No such file
or dir
ectory
Unable to access jarfile start.jar
C:\cygwin\bin


However, when I have this in my .bat file:
@echo off
C:
chdir C:\cygwin\bin
bash --login -i
rem 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 

I DO get the Cygwin command prompt. What am I missing here?


-- 
View this message in context: 
http://old.nabble.com/Autostart-Cygwin-on-Windows-boot-and-run-a-cygwin-command-tp31144428p31147631.html
Sent from the Cygwin list mailing list archive at Nabble.com.


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



Re: Autostart Cygwin on Windows boot and run a cygwin command

2011-03-14 Thread Jeremy Bopp
On 3/14/2011 14:21, PeterSmith wrote:
 Ok, so for now lets focus on the contents of the .bat file. I'll have a look
 at the startup of the bat later :)

Excellent idea, especially considering that it's not really a Cygwin
problem at that point. ;-)

 I now have this:
 @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 still gives me the exact same error:
 C:\start_cygwin.bat
 bash: line 0: cd:
 /cygdrive/e/solr/apache-solr-4.0-2010-10-12_08-05-48/example/: No such file
 or dir
 ectory
 Unable to access jarfile start.jar
 C:\cygwin\bin

I think the Unable to access... error message is actually coming from
java.exe.  That's likely because the cd before the java call failed
first, so you're not in the directory you expect to be when java is
started.  Make sure you don't have a typo in that path to which you're
trying to cd.

You may also consider replacing the ; in the command with  so that the
java command is never run if the cd fails.

-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



Re: Autostart Cygwin on Windows boot and run a cygwin command

2011-03-14 Thread PeterSmith



Jeremy Bopp-3 wrote:
 
 On 3/14/2011 14:21, PeterSmith wrote:
 Ok, so for now lets focus on the contents of the .bat file. I'll have a
 look
 at the startup of the bat later :)
 
 Excellent idea, especially considering that it's not really a Cygwin
 problem at that point. ;-)
 
 I now have this:
 @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 still gives me the exact same error:
 C:\start_cygwin.bat
 bash: line 0: cd:
 /cygdrive/e/solr/apache-solr-4.0-2010-10-12_08-05-48/example/: No such
 file
 or dir
 ectory
 Unable to access jarfile start.jar
 C:\cygwin\bin
 
 I think the Unable to access... error message is actually coming from
 java.exe.  That's likely because the cd before the java call failed
 first, so you're not in the directory you expect to be when java is
 started.  Make sure you don't have a typo in that path to which you're
 trying to cd.
 
 You may also consider replacing the ; in the command with  so that the
 java command is never run if the cd fails.
 
 -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
 
 
 

It indeed was Java and also because there was a typo in my directory :)
Thanks!
-- 
View this message in context: 
http://old.nabble.com/Autostart-Cygwin-on-Windows-boot-and-run-a-cygwin-command-tp31144428p31148119.html
Sent from the Cygwin list mailing list archive at Nabble.com.


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