Ask a Question related to PERL Miscellaneous, Design and Development.

  1. #1

    Default system und metachar

    Hi from a newby,

    I wanted to use system like: system("mv","*","targetDir);
    But * ist not interpreted at all and the commande failed.
    What would be the best way to do that ?

    Greetings from Paris,

    Christophe
    Tof Guest

  2. Similar Questions and Discussions

    1. Some 'System Calls' was Capturing system call output value
      On Friday, Nov 14, 2003, at 18:39 US/Pacific, Jerry Rocteur wrote: Wiggins is the one who deserves the point, since he was the one with the...
    2. System.Net.WebException occurred in system.web.services.dll - HTTP status 405: Method not allowed.
      Hi, Have anyone ever encountered an exception error: The request failed with HTTP status 405: Method not allowed when trying to remotely invoke a...
    3. The type System.Web.UI.WebControls.TextBox in Assembly System.Web...error
      I've been getting this error every since I installed InstallSqlState to handle my viewState Sessions. it only happens on 1 section of my asp.net...
    4. Method not found: System.Collections.Specialized.NameValueCollection System.Web.HttpRequest.get_QueryString().
      I just recently started getting the above error on a page I am posting MULTIPART/FORM-DATA. We have SoftArtisans FileUp component and Filter...
    5. How to: Network XP system to system running 2000?
      I have a desktop running XP. I have a laptop running 2000. They share an internet connection through a Linksys wireless router. My question...
  3. #2

    Default Re: system und metachar

    Tof wrote:
    > Hi from a newby,
    >
    > I wanted to use system like: system("mv","*","targetDir);
    > But * ist not interpreted at all and the commande failed.
    > What would be the best way to do that ?
    >
    > Greetings from Paris,
    >
    > Christophe
    Bonjour,

    Try: system( "mv * targetdir" );

    Shawn Corey Guest

  4. #3

    Default Re: system und metachar

    Tof <adjudant.tassin@laposte.net> wrote:

    > I wanted to use system like: system("mv","*","targetDir);

    This part of the description of the system() function will
    be important here:

    Note
    that argument processing varies depending on the
    number of arguments. If there is more than one
    argument in LIST, or if LIST is an array with more
    than one value, starts the program given by the
    first element of the list with arguments given by
    the rest of the list. If there is only one scalar
    argument, the argument is checked for shell
    metacharacters, and if there are any, the entire
    argument is passed to the system's command shell
    for parsing


    So your call above will not invoke a shell.

    > But * ist not interpreted at all

    Because it is the shell that interprets it, and there is no shell.

    > and the commande failed.
    > What would be the best way to do that ?

    Either expand it yourself:

    !system('mv', glob('*'), 'targetDir') or die "mv failed $!";
    #or
    !system('mv', <*>, 'targetDir') or die "mv failed $!";


    Or call system such that it _will_ invoke a shell (and accept
    all of the dangers that go with it):

    !system('mv * targetDir') or die "mv failed $!";


    --
    Tad McClellan SGML consulting
    [email]tadmc@augustmail.com[/email] Perl programming
    Fort Worth, Texas
    Tad McClellan Guest

  5. #4

    Default Re: system und metachar

    Tof wrote:
    > Hi from a newby,
    >
    > I wanted to use system like: system("mv","*","targetDir);
    > But * ist not interpreted at all and the commande failed.
    > What would be the best way to do that ?
    >
    When you hand system multiple strings, it directly invokes
    the first string as the program name, passing it the other
    strings as parameters. The shell is never invoked, so none
    of the shell metacharacters get interpreted. In order to
    get system to invoke the shell to parse your command line,
    you need to pass it only *one* string, like so:

    system("mv * targetDir");

    Chris Mattern

    Chris Mattern Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139