Skip to contentSkip to conversation

How to pass parameters containig options from variables

DISCUSSION [email protected] 4 participants 5 messages Sep 25, 2012

lore
Share & tools
lore
#0 lore raw

Hello list,

I am trying to pass these arguments

-N -p -F "not host foo"

to a binary, but

	ARGS="-N -p -F 'not host foo'"
	$DAEMON $ARGS

get's passed as 6 arguments and not 4.

Using xargs this works, but I'd like to not introduce that dependency:

	ARGS="-N -p -F 'not host foo'"
	echo $ARGS | xargs $DAEMON

Now for the complete picture, it's the init script for arpwatch. Options that should be passed to arpwatch can be specified by the sysadm in /etc/default/arpwatch with is sourced by the initscript and then passed (via start-stop-daemon) to the arpwatch binary.

This is on debian stable, package version 0.5.5.1-7.4

Stefan

Signature · 3 lines
Reader, suppose you were an idiot.  And suppose you were a member of
Congress.  But I repeat myself.
		-- Mark Twain
#1 lore raw

Hi,

Quoted 10 lines · On 2012-09-25 10:47 +0200, [email protected] wrote:

I am trying to pass these arguments

-N -p -F "not host foo"

to a binary, but

	ARGS="-N -p -F 'not host foo'"
	$DAEMON $ARGS

get's passed as 6 arguments and not 4.

eval $DAEMON $ARGS should work.

Signature · 4 lines
 --------------------------------------------------------------- 
| Olof Johansson                              http://stdlib.se/ |
|  irc: zibri                           https://github.com/olof |
 --------------------------------------------------------------- 
#2 lore raw

Hi,

Quoted 1 line

eval $DAEMON $ARGS should work.

That did it, thank you.

Regards,

Stefan

Signature · 3 lines
BOFH excuse #230:

Lusers learning curve appears to be fractal
#3 lore raw
Quoted 5 lines · On Sep 25, 2012, at 10:28, [email protected] wrote:
Quoted 2 lines

eval $DAEMON $ARGS should work.

That did it, thank you.

... but always beware of "eval" if you don't absolutely control the argument string. A single semicolon and someone owns your process.

-- gil

#4 lore raw
Quoted 6 lines · Paul Gilmartin
Quoted 2 lines · On Sep 25, 2012, at 10:28, [email protected] wrote:
Quoted 1 line

eval $DAEMON $ARGS should work.

That did it, thank you.

... but always beware of "eval" if you don't absolutely control the argument string. A single semicolon and someone owns your process.

For a configuration file that gets sourced, the person creating the configuration file already owns the process, so there is no added security by avoiding eval here.