public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Running Cygwin as a serivce and automatically executing a script
@ 2002-07-10 15:33 Dave
  2002-07-10 18:27 ` Jim.George
  2002-07-10 19:28 ` Huijing Zhou
  0 siblings, 2 replies; 3+ messages in thread
From: Dave @ 2002-07-10 15:33 UTC (permalink / raw)
  To: cygwin

After Spending a few hours hunting through mailing list archives and reading
the FAQ inside and out, I have decided to make a post to the list.

The Question:

I want to run Cygwin as a service on Windows 2000 Professional with service
pack 2 and get Cygwin to automatically run a script (in this instance a Perl
script).

Getting Cygwin to run as a service (that runs for any users) is not a
problem, I am currently using FireDaemon (http://www.firedaemon.com/) and
linking to a batch file, setting C:\cygwin as the working directory and
C:\cygwin\mybatfile.bat as the execution file.

The batch file is loaded as intended every time the machine is turned on,
however Cygwins behaviour is odd.

The batch files contains:

C:
chdir C:\cygwin\bin
bash --login -i
CD ~
CD mydir
perl myperl.pl

When I run the batch file normally it gets as far as opening the bash, using
the currently logged in user (which happens to be administrator).

When run as a service (with or without the service set to run as
administrator) it loads the bash, but the bash reports it cannot find the
/tmp dir. And it stops execution.

In both instance the script is not loaded.

I am not very experience with either Unix or Cygwin, so any help would be
great J

What I am trying to actually do?

The reason I wish to run it as a service is to hide the Cygwin window, as I
use the machine its on for many other things and having the bash window on
the taskbar is a pain, as its not actually doing anything, once the script
has been run.

If there is another way to load a script automatically and hide the Cygwin
window, I am all ears.

Direct Contact: dave@shadowxj5.co.uk - Dave



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Running Cygwin as a serivce and automatically executing a script
  2002-07-10 15:33 Running Cygwin as a serivce and automatically executing a script Dave
@ 2002-07-10 18:27 ` Jim.George
  2002-07-10 19:28 ` Huijing Zhou
  1 sibling, 0 replies; 3+ messages in thread
From: Jim.George @ 2002-07-10 18:27 UTC (permalink / raw)
  To: Dave; +Cc: cygwin

Dave,

	why not execute /usr/bin/perl with myperl.pl as the command line
prompt?  In other words don't worry about the rest of the bat file.

	Is it myperl.pl that uses the /tmp directory?  Have you tried
amending your perl script to use the full path for /tmp, i.e.
/cygdrive/<install-dir>/tmp

HTH,

Jim
On Wed, 10 Jul 2002, Dave wrote:

> After Spending a few hours hunting through mailing list archives and reading
> the FAQ inside and out, I have decided to make a post to the list.
>
> The Question:
>
> I want to run Cygwin as a service on Windows 2000 Professional with service
> pack 2 and get Cygwin to automatically run a script (in this instance a Perl
> script).
>
> Getting Cygwin to run as a service (that runs for any users) is not a
> problem, I am currently using FireDaemon (http://www.firedaemon.com/) and
> linking to a batch file, setting C:\cygwin as the working directory and
> C:\cygwin\mybatfile.bat as the execution file.
>
> The batch file is loaded as intended every time the machine is turned on,
> however Cygwins behaviour is odd.
>
> The batch files contains:
>
> C:
> chdir C:\cygwin\bin
> bash --login -i
> CD ~
> CD mydir
> perl myperl.pl
>
> When I run the batch file normally it gets as far as opening the bash, using
> the currently logged in user (which happens to be administrator).
>
> When run as a service (with or without the service set to run as
> administrator) it loads the bash, but the bash reports it cannot find the
> /tmp dir. And it stops execution.
>
> In both instance the script is not loaded.
>
> I am not very experience with either Unix or Cygwin, so any help would be
> great J
>
> What I am trying to actually do?
>
> The reason I wish to run it as a service is to hide the Cygwin window, as I
> use the machine its on for many other things and having the bash window on
> the taskbar is a pain, as its not actually doing anything, once the script
> has been run.
>
> If there is another way to load a script automatically and hide the Cygwin
> window, I am all ears.
>
> Direct Contact: dave@shadowxj5.co.uk - Dave
>
>
>
> --
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> Bug reporting:         http://cygwin.com/bugs.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/
>


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Running Cygwin as a serivce and automatically executing a script
  2002-07-10 15:33 Running Cygwin as a serivce and automatically executing a script Dave
  2002-07-10 18:27 ` Jim.George
@ 2002-07-10 19:28 ` Huijing Zhou
  1 sibling, 0 replies; 3+ messages in thread
From: Huijing Zhou @ 2002-07-10 19:28 UTC (permalink / raw)
  To: Dave; +Cc: cygwin

> I want to run Cygwin as a service on Windows 2000 Professional with service
> pack 2 and get Cygwin to automatically run a script (in this instance a Perl
> script).

What you means is, you want to run *bash* as a service, not cygwin. 
Since when we say cygwin, we either mean the cygwin1.dll, or the whole 
cygwin platform.

 > [...]
 >
> The batch files contains:
> 
> C:
> chdir C:\cygwin\bin
> bash --login -i
> CD ~
> CD mydir
> perl myperl.pl

The batch file is plainly wrong. Even if "bash --login -i" would succeed 
(which does not, as you later describe), the batch would hang here since 
bash is waiting for input and not getting any. "CD ~" will not be 
executed at all since it's actually outside bash. This means even if 
"bash --login -i" would time out (it definitely *does not*), "CD ~" and 
the other two lines after it will be executed in Windows command 
interpreter environment as a Windows command and not in bash, where "CD 
~" would fail since Windows does not know about "~".

> When I run the batch file normally it gets as far as opening the bash, using
> the currently logged in user (which happens to be administrator).

Exactly. bash opened and no further.

And if you want a "fake service" (like here) to run, test it first as 
normal programme (which you did, but without success). If the batch file 
fails "normally", how could it work as a service?

> When run as a service (with or without the service set to run as
> administrator) it loads the bash, but the bash reports it cannot find the
> /tmp dir. And it stops execution.

Where did you get this "report" by bash if the batch runs as a service 
(non-interactive and non-visible)? How does the exact wording of this 
report look like?

> In both instance the script is not loaded.

Well, more than one issue stands in its way.

> [...]
> 
> The reason I wish to run it as a service is to hide the Cygwin window, as I
> use the machine its on for many other things and having the bash window on
> the taskbar is a pain, as its not actually doing anything, once the script
> has been run.

Wrong. Either you want the script to run *once* when the system starts 
up (as you stated before), *before* the first user logs in. Or you want 
the script to run every time a user logs in. In first case you need to 
run it as a service, in second case run it in "Startup" folder or so. In 
a third case, if you want to run the script, say, daily, you may want to 
use Windows' "Scheduled Tasks".

> If there is another way to load a script automatically and hide the Cygwin
> window, I am all ears.

Besides the question of when to call the script, I think what you need 
first is to call bash correctly to start the script, something like:

bash -c perl myperl.pl

In any case, do not use "bash -i" which means "interactive" because you 
actually do not want to interact with bash here. In case you don't know, 
type "man bash" will give you a documentation about the bash shell.

Regards,

Huijing

-- 
Huijing Zhou <hj@N.O.S.P.A.M.cip.wiwi.uni-karlsruhe.de>
CIP Computer Lab, Faculty of Economics
University of Karlsruhe, Germany
http://www2.wiwi.uni-karlsruhe.de


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-07-11  1:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-10 15:33 Running Cygwin as a serivce and automatically executing a script Dave
2002-07-10 18:27 ` Jim.George
2002-07-10 19:28 ` Huijing Zhou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).