Closed ASchmidt1 closed 1 year ago
No worries! I've added a small note to the README just in case.
Hi Matthew,
I’m embarrassed to say – I just can’t figure out how to use it to add a “.cmd” batch procedure, plus its parameters, as service. I have that working with NSSM, but was hoping to replace NSSM with Shawl – but I’m stumped.
I don’t think the documentation makes clear whether I’m supposed to specific the .cmd file itself as the “command”, followed by its parameters as one string, or if I’m supposed to shell executable as the “command” and the .cmd file with parameters as the input to the command shell, etc etc.
Of about 10 combinations of different quoting/no quoting etc., here two that are rejected for bad syntax:
shawl add --log-dir "C:\Logfiles" --name "Solr (Lucene Search Server)" --cwd "C:\solr\8.11\bin\" -- "C:\solr\8.11\bin\solr.cmd" "start -f -s E:\Solr_Home"
shawl add --log-dir "C:\Logfiles" --name "Solr (Lucene Search Server)" --cwd "C:\solr\8.11\bin\" -- "C:\Windows\System32\cmd.exe" "/C solr.cmd start -f -s E:\Solr_Home"
Any guidance would be appreciated.
Best Regards Andy
From: Matthew Kennerly @.> Sent: Thursday, May 18, 2023 12:43 AM To: mtkennerly/shawl @.> Cc: Andy Schmidt @.>; State change @.> Subject: Re: [mtkennerly/shawl] -help missing most command line options? (Issue #29)
No worries! I've added a small note to the README just in case.
— Reply to this email directly, view it on GitHubhttps://github.com/mtkennerly/shawl/issues/29#issuecomment-1552391049, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AC36SOBYMF5HHZ4LY6TVY3LXGWSGBANCNFSM6AAAAAAYFTYUYA. You are receiving this because you modified the open/close state.Message ID: @.**@.>>
That's okay; no harm in asking :)
Actually, while writing up an example, I realized that cmd.exe rejects the UNC working directory that Shawl tries to give it when you use --cwd
, which makes cmd.exe fall back to an incorrect directory. Not sure if that was part of the issue you were facing, but I just released the fix in v1.2.0, so I recommend upgrading just in case.
Aside from that, you only need to quote the individual arguments, and only if they contain spaces. Give this a try:
shawl add --log-dir C:\Logfiles --name "Solr (Lucene Search Server)" --cwd C:\solr\8.11\bin -- solr.cmd start -f -s E:\Solr_Home
If that doesn't work, then please show me the exact error you get.
Here's a full example using Command Prompt:
$ type C:\tmp\script.cmd
echo script cwd = %cd%, arg 1 = %1, arg 2 = %2 >> script.log
$ shawl.exe add --name shawl-demo --cwd C:\tmp -- script.cmd "foo bar" baz
$ sc start shawl-demo
$ type C:\tmp\script.log
script cwd = C:\tmp, arg 1 = "foo bar", arg 2 = baz
I don’t think the documentation makes clear whether I’m supposed to specific the .cmd file itself as the “command”, followed by its parameters as one string, or if I’m supposed to shell executable as the “command” and the .cmd file with parameters as the input to the command shell, etc etc.
It's pretty flexible. A *.cmd
file or cmd.exe
are both fine, but the arguments should be passed as separate strings (unless your program really expects a single string with all the options).
You should be able to take most valid CLI invocations and stick them after the --
as-is, although you do have to take care with nested quotes. Here's an example using cmd.exe (fortunately /C
doesn't seem to actually require quotes, which makes it easier):
$ shawl.exe add --name shawl-demo --cwd C:\tmp -- cmd.exe /C script.cmd "foo bar" baz
$ sc start shawl-demo
$ type C:\tmp\script.log
script cwd = C:\tmp, arg 1 = "foo bar", arg 2 = baz
Thanks, Matt.
The new version worked with the suggested command line. And, I was able to start the service.
The error I used to get seemed to pick up arbitrary items behind my “command” and interpret them as syntax – e.g., it had picked up the “start” and complained that start was not a valid shawl command, etc.
Best Regards Andy
Reply to this email directly, view it on GitHubhttps://github.com/mtkennerly/shawl/issues/29#issuecomment-1554227077, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AC36SOGBQB6M4RWYYLEQF53XG4VKBANCNFSM6AAAAAAYFTYUYA. You are receiving this because you modified the open/close state.Message ID: @.**@.>>
First of all: Thank you to all contributors.
Never mind...
shawl add --help
provided much of the information sought.