Xymon Mailing List Archive search

ShellExecute api call

3 messages in this thread

list Al Jeffcoat · Mon, 8 May 2006 12:37:59 -0400 ·
Hello All,

 
I've got a programmer here trying to send a status message to hobbit
from a windows machine.  He's having a problem executing the bb code.  I
myself am not a programmer, so I figured I'd pass on his e-mail and see
if anyone else knows the answer to his problem.

 
TIA,

 
Al

 
--- Quote ---

There is a problem doing this from within a program. The shellexecute
function requires you to pass the program name and parameters seperate.

 
E.G.,

 
program = "bb.exe" 

parameters = "hobbit status kn306109.dtr-status red
<center>DTR-STATUS</center><br>Last Failure = 05/04/20 06 00:00:01 Last
Success = 05/08/2006 00:00:01<br>Copies = 50"

 
(hobbit is not part of the program name and that is why it can't be part
of program name)

 
If I try to simulate this on command line with   

 
bb "hobbit status kn306109.dtr-status red
<center>DTR-STATUS</center><br>Last Failure = 05/04/20 06 00:00:01 Last
Success = 05/08/2006 00:00:01<br>Copies = 50"

 
I get

 
 bb: incorrect number of arguments

 
--- /Quote ---

 
I know the format of a message, and if I change his message to read

 
bb hobbit "status kn306109.dtr-status red
<center>DTR-STATUS</center><br>Last Failure = 05/04/20 06 00:00:01 Last
Success = 05/08/2006 00:00:01<br>Copies = 50"

 
It works fine.

 
My thought was to write a "wrapper" batch file.

 
I'm open to any other ideas.
list Henrik Størner · Tue, 9 May 2006 09:29:10 +0200 ·
quoted from Al Jeffcoat
On Mon, May 08, 2006 at 12:37:59PM -0400, Jeffcoat, Al wrote:
I've got a programmer here trying to send a status message to hobbit
from a windows machine.  He's having a problem executing the bb code.  I
myself am not a programmer, so I figured I'd pass on his e-mail and see
if anyone else knows the answer to his problem.

There is a problem doing this from within a program. The shellexecute
function requires you to pass the program name and parameters seperate.

program = "bb.exe" 

parameters = "hobbit status kn306109.dtr-status red
<center>DTR-STATUS</center><br>Last Failure = 05/04/20 06 00:00:01 Last
Success = 05/08/2006 00:00:01<br>Copies = 50"
I suspect some sort of quoting is needed to pass this as the two
parameters bb.exe expects - first the IP/hostname of the server, then
the actual status message.

I browsed through the MSDN site, and came across the docs for the
ShellExecuteEx function - at the bottom there is an example of 
how to quote parameters. Perhaps this applies to ShellExecute 
as well:

    To include double quotation marks in lpParameters, enclose each 
    mark in a pair of quotation marks, as in the following example.

        sei.lpParameters = "An example: \"\"\"quoted text\"\"\"";

    In this case, the application receives three parameters: An,
    example:, and "quoted text".

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/structures/shellexecuteinfo.asp

Obviously, bb.exe doesn't want the quotes, but perhaps it should be done
as 
parameters = "hobbit \"status kn306109.dtr-status red <center>DTR-STATUS</center><br>Last Failure = 05/04/20 06 00:00:01 Last Success = 05/08/2006 00:00:01<br>Copies = 50\""


Regards,
Henrik
list T.J. Yang · Tue, 09 May 2006 06:12:37 -0500 ·
I like to suggest not to generate client code when doing "configure 
--server" .

I got following currently.

bash-2.05a# ls /opt/hobbits/
bin     client  etc     ext     man     server  web     www
bash-2.05a#

bash-2.05a# ls /opt/hobbits/client/
bin           etc           ext           logs          runclient.sh  tmp
bash-2.05a#


I think(IMHO) the client binaries code should only comes from "configure 
--client".


T.J. Yang