Re: How to pass arguments with '*' to execvp()?

From: Alex Vinokur (alexvn_at_x-privat.org)
Date: 11/26/05

  • Next message: Pascal Bourguignon: "Re: How to pass arguments with '*' to execvp()?"
    Date: 26 Nov 2005 11:50:02 +0100
    
    

    "Pascal Bourguignon" <spam@mouse-potato.com> wrote in message news:87fypjvm8u.fsf@thalassa.informatimago.com...
    > "Alex Vinokur" <alexvn@users.sourceforge.net> writes:
    >
    > > I tried to execute the following command line:
    > >
    > > strcpy (cmd, "ls");
    > > strcpy (args[0], "ls");
    > > strcpy (args[1], "-l");
    > > strcpy (args[2], "*.c");
    > > args[3] = NULL;
    > >
    > > execvp (cmd, args);
    > >
    > > However I have got an error message:
    > > ----------------------------
    > > ls: '*.c': No such file or directory
    > > ----------------------------
    > >
    > >
    > > How to pass arguments with '*' to execvp()?
    >
    > Using opendir, readdir and fnmatch.
    [snip]

    OK.
    I found sample at http://docs.hp.com/en/B2355-90694/fnmatch.3C.html

    -----------------------
    pattern = "*.c";

    while(dp = readdir(dirp)){
        if((fnmatch(pattern, dp->d_name,0)) == 0){
            /* do processing for match */
                  ...
        }
    }
    -----------------------

    But how to apply that to passing args to execvp (cmd, args) ?

    -- 
     Alex Vinokur
         email: alex DOT vinokur AT gmail DOT com
         http://mathforum.org/library/view/10978.html
         http://sourceforge.net/users/alexvn
    

  • Next message: Pascal Bourguignon: "Re: How to pass arguments with '*' to execvp()?"

    Relevant Pages