spaces in arguments

Kenneth.ray kenneth.ray at travelersla.com
Thu Sep 5 20:36:51 CEST 2002


the behavior your describing is exactly how you would define an argument, however,
the best way to handle this in perl is to assign the @ARGV list to a variable and then
take that variable and assign it to what you need to assign it as a string.
I believe you can do this by using a $LIST=@list; variable, if that doesnt work try
a join() function on the list.
hope this helps..
your code is doing what you told it to, tell it something different and you'll be set.
remember in perl that  all arguments are assigned to a default list called ARGV (at least that is
what it says in my book)




> --__--__--
>
> Message: 1
> Date: Wed, 04 Sep 2002 17:35:23 -0400
> From: Russell Scibetti <russell at quadrix.com>
> Organization: Quadrix Solutions Inc.
> To: Gunnar Hellekson <ghelleks at yahoo.com>,
>         nagios-users at lists.sourceforge.net
> Subject: [Nagios-users] Re: [Nagios-devel] Spaces in arguments?
>
> For functionality sake, try adding a \ before each space to escape the
> space.  That might work.
>
> Russell Scibetti
>
> Gunnar Hellekson wrote:
>
> >This is a message I sent to nagiosplug-devel.  This behavior appears to be
> >coming from embedded perl, so I'm sending it here.  Seems as though the
> >argument parsing behavior is drastically different between checks run under
> >embedded perl and those run more conventionally.
> >
> >
> >------ Forwarded Message
> >From: Gunnar Hellekson <ghelleks at yahoo.com>
> >Date: Tue, 03 Sep 2002 01:12:05 -0400
> >To: nagiosplug-devel <nagiosplug-devel at lists.sourceforge.net>
> >Subject: [Nagiosplug-devel] Spaces in arguments?
> >
> >
> >I've pored through the Nagios code, posted questions, and tried to find
> >working examples.  I'm starting to think I'm stupid.  I've written a plugin
> >which takes, among other things, a string containing spaces.
> >
> >define command {
> >command_name my_plugin
> >command_line $USER1$/my_plugin -C '$ARG1$' -T $ARG2$
> >}
> >
> >define service {
> >host_name my-host
> >service_description buggy-service
> >use generic-service
> >check_command my_plugin!A String With Spaces!AnotherValue
> >}
> >
> >Running this as nagios works, of course:
> >
> >   ./my_plugin -C 'A String With Spaces' -T AnotherValue
> >
> >When run in Nagios, it behaves as if:
> >
> >   ./my_plugin -C \'A String With Spaces\' -T AnotherValue
> >
> >In other words, argv is:
> >0 == ./my_plugin
> >1 == -C
> >2 == 'A
> >3 == String
> >etc.
> >
> >
> >I have tried:
> >
> >   * wrapping $ARG1$ in both (') and (") characters
> >   * wrapping $ARG1$ in escaped quotes (\'), (\")
> >   * wrapping the first argument in the service declaration (A String...)
> >     in ('), (") and escaped quotes (\'), (\")
> >
> >In every case, the command is executed as if each word of $ARG1$
> >is a seperate argument.
> >
> >This is with Nagios 1.0b5, Solaris 2.6.  The documentation to popen()
> >and Nagios tell me that I should have to, at most, place a single quote (')
> >around the $ARG1$ string in the check_command directive.  Yet, no
> >joy.
> >
> >Can anyone confirm this?  Has anyone been able to get arguments
> >containing spaces fed into their plugins?
> >
> >I would recompile with DEBUG1 so I could see the raw_command and
> >processed_command, but nagios dumps core each time I've tried.
> >
> >Anyone?
> >
> >------ End of Forwarded Message
> >




-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390




More information about the Users mailing list