The situation:

1) The following work as expected:

[08:39:43 /tmp]# powercom -m "Advice Partner/King PR750" -s 00131581 /dev/ttyS1
Network UPS Tools - PowerCom UPS driver 0.01 (0.44.0-pre4)
[08:40:06 /tmp]#


2) Now I am trying to run the same command with shell variables:

[08:40:06 /tmp]# DAEMON=powercom
[08:41:59 /tmp]# ARGUMENTS='-m "Advice Partner/King PR750" -s 00131581 
/dev/ttyS1'
[08:42:09 /tmp]# echo $DAEMON $ARGUMENTS
powercom -m "Advice Partner/King PR750" -s 00131581 /dev/ttyS1
[08:42:17 /tmp]# `echo $DAEMON $ARGUMENTS`
Network UPS Tools - PowerCom UPS driver 0.01 (0.44.0-pre4)
Unable to open (1) Partner/King: No such file or directory
[08:42:25 /tmp]# 


But here it has an error. It looks to me the same command in both cases. 
Obviously it is not. But what is the difference and how to fix it?

Some background: The 2nd activation fails while powercom is parsing its 
command line arguments. The parsing is done with getopt (3). More specifically 
it is done with:
        getopt(argc, argv, "+hd:k:m:s:")
The failure in the 2nd activation is probably due to the fact that after 
getopt attaches the Advice argument to the -m switch it is bailing out since 
it has the + character and got a non option argument (Partner/King). And the 
next command of powercom expects a serial device (/dev/ttyS1) and can not 
handle something else (Partner/King).
Why the same thing does not happen with the 1st activation of powercom? 
-- 
        
        --  Shaul Karl <[EMAIL PROTECTED]>

        Donate free food to the world's hungry: see http://www.thehungersite.com



=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to