> Hi
> 
> Shaul Karl wrote:
> [Charset iso-8859-1 unsupported, filtering to ASCII...]
> > > Shaul Karl wrote:
> > > > > > 
> > > > > > [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]# 
> > > > > > 
> > > > > 
> > > > > How about trying the following:
> > > > > 
> > > > > `echo $DAEMON "$ARGUMENTS"`
> > > > > 
> > > > > The outer back-quotes are unnecessary in this case (running from the
> > > > > command line) but I assume you want to put this in some script.
> > > > > 
> > > > > The problem is, of course, that $ARGUMENTS gets separated by the shell
> > > > > into "Advice" "Parnet/King" "PR750". The extra quotes should do the
> > > > > trick.
> > > > > 
> > > > > -- Nimrod.
> > > > 
> > > > 
> > > > It is protected with quotes ("") in the first place. Why will it get separated 
> > > > by bash into 3 strings?
> > > 
> > > from bash(1):
> > >    Word Splitting
> > >        The  shell  scans the results of parameter expansion, com_
> > >        mand substitution, and arithmetic expansion that  did  not
> > >        occur within double quotes for word splitting.
> > > 
> > > Of course, it is not trivial how to apply that to your example. As I
> > > understand, 'did not occur within double quotes' refers only to the
> > > original text, and not to 'the results of'.
> > > If you want to go over the whole Expansion process, I see no way other
> > > than rerun the shell, as in
> > > sh -c "$DAEMON $ARGUMENTS"
> > > (This will probably not be exactly what you need, but you see what I mean).
> > 
> > 
> > sh -c "$DAEMON $ARGUMENTS" is working.
> > But it is not what I need. I need it with something like `echo $DAEMON 
> > $ARGUMENTS` because the final result should be to gives this to shell vars to 
> > debian start-stop-daemon as in
> >     start-stop-daemon --start --verbose --exec /sbin/$DAEMON -- $ARGUMENTS
> > 
> > Isn't there a way to prevent the shell from removing the quotes? Perhaps with 
> > a more complicated structure of single and double quotes in the definition of 
> > ARGUMENTS?
> 
> 1. After thinking again, I don't think there is a simple solution. As I
> understand, quoting is performed much before variable expansion, and you
> can't force a different behaviour. (You can play with $IFS, and get other
> problems).
> 2. One solution, of course, is to make DAEMON a shell script that calls the
> real deamon. Ugly, but it might work.
> 3. Why do you insist on exactly this syntax? I have ~80 scripts under
> /etc/init.d, and only few of them (5-10?) have similar definitions.
> Many of them do not use any variables in the arguments, other define specific
> stuff, not one variable for many arguments.
> Why not define $MODEM_NAME, $MODEM_DEVICE, $MODEM... (whatever -s means), and
> call start-stop-daemon with -- -m "$MODEM_NAME" -s ... $MODEM_DEVICE etc.?
> 




The problem is that different daemons are having different number of arguments.
This can be solved by having a 10 shell vars ARG1, ARG2, ... ARG10 (since 
there are probably none with more then 10 arguments) and looping or otherwise 
assigning the non empty one to the next non assigned arg. But this looks to me 
inappropriate for an init script.




> > 
> > 
> > BTW: ps does not show the quotation:
> > 
> > [01:25:29 /tmp]# ps axf |grep powercom | grep -v grep
> >  8739 pts/9    S      0:00 powercom -m Advice Partner/King PR750 -s 00131581 
> > /dev/ttyS1
> > [01:26:02 /tmp]# 
> > 
> > 
> > > 
> > > > In any case, without the outer back-quotes that you put the DAEMON and 
> > > > ARGUMENTS vars are simply being displayed. And with them I am getting the 
> > > > previous behavior.
> > > > 
> > > > 
> > > > [23:26:14 /tmp]# echo $DAEMON "$ARGUMENTS"
> > > > powercom -m "Advice Partner/King PR750" -s 00131581 /dev/ttyS1
> > > > [23:31:53 /tmp]# echo $DAEMON $ARGUMENTS 
> > > > powercom -m "Advice Partner/King PR750" -s 00131581 /dev/ttyS1
> > > > [23:31:59 /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
> > > > [23:32:14 /tmp]# 
> > > > 
> > > > 
> > > > In case it might give someone a hint, here is the main part of powercom.c. The 
> > > > command line arguments get parsed here.
> > > > 
> > > > [23:35:20 models]$ grep main powercom.c -A 56
> > > > int main (int argc, char **argv)
> > > > {
> > > >         char    *portname, *prog, raw_data[NUM_OF_BYTES_FROM_UPS],
> > > >                 tmp[256], *ups_model = 0, *ups_serial_num = 0;
> > > >         int     i;
> > > > 
> > > >         printf ("Network UPS Tools - PowerCom UPS driver 0.01 (%s)\n",
> > > >                                                                 UPS_VERSION);
> > > >         openlog ("powercom", LOG_PID, LOG_FACILITY);
> > > > 
> > > >         prog = argv[0];
> > > > 
> > > >         if (argc == 1) {
> > > >                 printf("Error: no device specified!\n");
> > > >                 help (prog);
> > > >         }
> > > > 
> > > >         while ((i = getopt(argc, argv, "+hd:k:m:s:")) != EOF) {
> > > >                 switch (i) {
> > > >                         case 'd':
> > > >                                 sddelay = atoi(optarg);
> > > >                                 break;
> > > >                         case 'h':
> > > >                                 help(prog);
> > > >                                 break;
> > > >                         case 'k':
> > > >                                 forceshutdown(optarg);
> > > >                                 break;
> > > >                         case 'm':
> > > >                                 ups_model = optarg;
> > > >                                 break;
> > > >                         case 's':
> > > >                                 ups_serial_num = optarg;
> > > >                                 break;
> > > >                         default:
> > > >                                 help(prog);
> > > >                                 break;
> > > >                 }
> > > >         }
> > > > 
> > > >         argc -= optind;
> > > >         argv += optind;
> > > > 
> > > >         droproot(); 
> > > > 
> > > >         portname = NULL;
> > > >         for (i = strlen(argv[0]); i >= 0; i--)
> > > >                 if (argv[0][i] == '/') {
> > > >                         portname = &argv[0][i+1];
> > > >                         break;
> > > >                 }
> > > > 
> > > >         if (portname == NULL) {
> > > >                 printf ("Unable to abbreviate %s\n", argv[0]);
> > > >                 exit (1);
> > > >         }
> > > > 
> > > > [23:35:27 models]$
> > > > 
> > > > 
> > > > -- 
> > > >         
> > > >         --  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]
> > > > 
> > > 
> > >   didi
> > 
> > -- 
> >     
> >     --  Shaul Karl <[EMAIL PROTECTED]>
> > 
> >     Donate free food to the world's hungry: see http://www.thehungersite.com
> > 
> > 
> 
>       didi

-- 
        
        --  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