[uClibc] usage problem (linux - ash - system command)

Peter Kjellerstedt peter.kjellerstedt at axis.com
Tue Feb 1 11:34:41 UTC 2005


Well, that is a messy way of doing it, but I assume that's due to 
you having failed your first attempts, and is testing around.

The following ought to work (untested):

char origbuff[] = "00:01:02:03:04:05  00:05:04:03:02:01";
int count = 2;

sprintf(cmd, "/var/xxx/usr/sbin -s macacl %d \"%s\"", count, origBuff);
system(cmd);

Btw, the path & executable '/var/xxx/usr/sbin' looks suspicious. 
Is that actually what you use, or a typo in the mail?
That should be the name of the executable (and its path unless 
the executable is in one of the paths specified by the environment
variable $PATH).

//Peter

> -----Original Message-----
> From: Philip Rakity [mailto:prakity at yahoo.com] 
> Sent: Tuesday, February 01, 2005 09:16
> To: Peter Kjellerstedt
> Cc: uclibc at uclibc.org
> Subject: RE: [uClibc] usage problem (linux - ash - system command)
> 
> Hi Peter,
> 
> ./aniSdkTool is in the path --
> 
> The code snippet is as follows:
> 
> char bs = '\\'l
> char quote '"';
> char origbuff[] = "00:01:02:03:04:05  00:05:04:03:02:01";
> int count = 2;
> 
> sprintf (cmd, "/var/xxx/usr/sbin -s macacl %d %c%c%s%c%c", count, bs,
> quote, origBuff, bs, quote);
> 
> system(cmd);
> 
> If I do the following things work --
> 
> system ("echo %s > /var/pmr", cmd)
> system("sh /var/pmr);
> 
> Philip
> ======
> --- Peter Kjellerstedt <peter.kjellerstedt at axis.com> wrote:
> 
> > In cases like this, it is always a good idea to provide
> > a snippet of the actual code in use, as well as an extract 
> > of any debug messages.
> > 
> > Here is a small code example with two ways to use the system() 
> > call to call ls with your arguments (I use ls as it will print
> > the arguments when it fails to find them):
> > 
> > #include <stdlib.h>
> > 
> > int main()
> > {
> >   system("ls 1 2 \"00:11:22:33:44:55    00:11:22:44:55:66\"");
> >   system("ls 1 2 '00:11:22:33:44:55    00:11:22:44:55:66'");
> >   return 0;
> > }
> > 
> > Are you sure it is the arguments that is the problem, and not
> > for example that the aniSdkTool cannot be found in the current 
> > working directory?
> > 
> > //Peter
> > 
> > > -----Original Message-----
> > > From: uclibc-bounces at uclibc.org 
> > > [mailto:uclibc-bounces at uclibc.org] On Behalf Of Philip Rakity
> > > Sent: Tuesday, February 01, 2005 08:38
> > > To: uclibc at uclibc.org
> > > Subject: [uClibc] usage problem (linux - ash - system command)
> > > 
> > > I am writing a c program that uses the system command.
> > > 
> > > I am trying to use the system command to pass the following 
> > > stringfor processing.  The double quotes are important.  
> > > I am using busybox ash.
> > > 
> > > ./aniSdkTool 1 2 "00:11:22:33:44:55    00:11:22:44:55:66"
> > > 
> > > I use sprintf to built the string. 
> > > 
> > >  I have tried backslashing the " (double quotes)  eg \"
> > > ./aniSdkTool 1 2 \"00:11:22:33:44:55    00:11:22:44:55:66\"
> > > 
> > > I have tried single quoting the the " eg  '"  or "'
> > > ./aniSdkTool 1 2 '"00:11:22:33:44:55    00:11:22:44:55:66"'
> > > 
> > > The command fails HOWEVER if I echo the cmd to a /var/xxx 
> > > file and then cat the command it looks just fine. 
> > > looks like the line above with the quotes
> > > 
> > >  I can do the following from the shell  (console)
> > > 
> > > sh /var/xxx  works just fine 
> > > as well as
> > > ./var/xxx  (one execute premission is given to the file)
> > > 
> > > any ideas ?



More information about the uClibc mailing list