public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
To: cygwin@cygwin.com
Subject: Re: cygrunsrv: trailing command line arguments not allowed
Date: Sat, 20 Apr 2024 08:56:28 -0600	[thread overview]
Message-ID: <d725d594-09cb-4540-96a1-ee60470998a0@SystematicSW.ab.ca> (raw)
In-Reply-To: <b3bf6422-0259-28d7-26a4-f0149c1371e9@cs.umass.edu>

On 2024-04-20 06:31, Eliot Moss via Cygwin wrote:
> On 4/20/2024 8:12 AM, enrique--- via Cygwin wrote:
>> Hello,
>>
>> I am trying to install a service manually in an attempt to understand why 
>> cron-config did not work for me.
>>
>> So, I did this:
>>
>>> $ net stop cron
>>> Tjenesten Cron daemon stopper .
>>> Tjenesten Cron daemon ble stoppet.
>>>
>>> $ cygrunsrv -R cron
>>>
>>> $ cygrunsrv -I -p /usr/sbin/cron.exe -a -n
>>> cygrunsrv: Trailing commandline arguments not allowed
>>> Try `cygrunsrv --help' for more information.
>>
>> I also tried a number of other combinations and orders of arguments, all with 
>> similar results.
>>
>> What am I doing wrong?

> I would try --args '-n' instead of -a -n.  Perhaps some other
> variation of quoting will be needed to make clear to cygrunsrv
> that the -n is for the application, not for cygrunsrv.

Unadorned options anywhere on the command line are parsed by getopt, which is 
why the options are quoted by cron-config:

$ awk '/cygrunsrv\s-I/,/[^\\]$/' /usr/bin/cron-config
                 if cygrunsrv -I cron -p /usr/sbin/cron -e CYGWIN="${cygenv}" -e 
TMP="/tmp" \
                     -e TEMP="/tmp" -a "-n" -d "Cron daemon" -u "$cyg_username" 
-w "$password"
                 if cygrunsrv -I cron -p /usr/sbin/cron -e CYGWIN="${cygenv}" \
                     -a "-n" -d "Cron daemon"

I have normally found it more useful to run Cygwin *-config as elevated admin, 
and if from cmd with Cygwin /bin/ in path, then as `bash -c /usr/bin/*-config`.

You can modify settings either with:

	$ cygrunsrv -E $srv; cygrunsrv -R $srv; cygrunsrv -I $srv ...

possibly adding:

	-d, --disp "CYGWIN Cron daemon"
	-c, --chdir `cygpath -m /`
	-O, --preshutdown
	-y, --dep syslog-ng ...

or with:

$ sc config help
DESCRIPTION:
         Modifies a service entry in the registry and Service Database.
USAGE:
         sc <server> config [service name] <option1> <option2>...

OPTIONS:
NOTE: The option name includes the equal sign.
       A space is required between the equal sign and the value.
       To remove the dependency, use a single / as dependency value.
  type= <own|share|interact|kernel|filesys|rec|adapt|userown|usershare>
  start= <boot|system|auto|demand|disabled|delayed-auto>
  error= <normal|severe|critical|ignore>
  binPath= <BinaryPathName to the .exe file>
  group= <LoadOrderGroup>
  tag= <yes|no>
  depend= <Dependencies(separated by / (forward slash))>
  obj= <AccountName|ObjectName>
  DisplayName= <display name>
  password= <password>

for example:

$ sc cron config start= delayed-auto DisplayName= "CYGWIN Cron daemon" \
	depend= syslog-ng

or

$ s=/proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/cron; \
   regtool set -d $s/KEY DWORD-VALUE; \
   ...

giving something like:

$ s=/proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/cron; \
   for p in {'',/Parameters{,/Environment}}; do \
	echo; echo $s$p:; regtool list -v $s$p;
   done

/proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/cron:
Parameters/ ()
DisplayName (REG_SZ) = "CYGWIN Cron daemon"
Type (REG_DWORD) = 0x00000010 (16)
Start (REG_DWORD) = 0x00000002 (2)
ErrorControl (REG_DWORD) = 0x00000001 (1)
ImagePath (REG_EXPAND_SZ) = ".../bin/cygrunsrv.exe"
ObjectName (REG_SZ) = "LocalSystem"
Description (REG_SZ) = "Cygwin Command Execution Scheduler cron daemon"
DelayedAutoStart (REG_DWORD) = 0x00000001 (1)
DependOnService (REG_MULTI_SZ) = "syslog-ng"

/proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/cron/Parameters:
Environment/ ()
AppPath (REG_SZ) = "/usr/sbin/cron"
AppArgs (REG_SZ) = "-n"
Preshutdown (REG_DWORD) = 0x00000001 (1)

/proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/cron/Parameters/Environment:
CYGWIN (REG_SZ) = " "

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                 -- Antoine de Saint-Exupéry

  reply	other threads:[~2024-04-20 14:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-20 12:12 cygrunsrv: trailing command line arguyments " enrique
2024-04-20 12:31 ` Eliot Moss
2024-04-20 14:56   ` Brian Inglis [this message]
2024-04-20 16:05 ` enrique

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d725d594-09cb-4540-96a1-ee60470998a0@SystematicSW.ab.ca \
    --to=brian.inglis@systematicsw.ab.ca \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).