It could be that it is the Windows shell that mangles the parameters of the system command and not Perl (and that answers also your statement: considering what a mess perl's handling of unicode is).

It could also be that it is not a unicode issue but a filename/parameters quoting issue which somehow surfaces with unicode filenames in a Windows shell/command-prompt.

Ideally, you want to run fsutil without you or Perl opening a Windows shell (command prompt). As I have very little knowledge for this OS, I don't know if there exists a fsutil.exe or if it is a shell builtin. In the latter case you absolutely need the shell. I guess. So ignore the rest of the post. Edit: karlgoethebier++ reports below that there exists a fsutil.exe. So, logically thinking, you do not need the Windows shell.

Further more, system states: When system's arguments are executed indirectly by the shell, results and return codes are subject to its quirks. I would stress the word "quirks". On top of that, shelling out on Windows may impose extra challenges because of lack of Perl implementation for fork in this OS (not Perl's fault, see perlfork).

That said, there are quite a few ways to execute a shell command in Perl (backtics, various forms of system(), IPC::run3, possibly others). I would experiment with those before resorting to the batch file solution offered by harangzsolt33 solely because of its roundabout way but, otherwise, it is a good solution which "catches the mouse" so-to-speak.

As an example (and noting system()'s documentation AND, particularly, system() Windows issues) here is how to use the system PROGRAM LIST form (not tested and I am ignorant of Windows):

my $CMD = 'fsutil.exe'; # assuming such thing exists, see above my @PARAMS = ('file', 'setShortName', # borrowed from [atcroft] but without outermost quotes q/C:\Users\James\Music\/ . qq/\N{U+22283}\N{U+35486}/ . qq/\N{U+25079}\N{U+24565}/ . qq/\N{U+32769}\N{U+27468}/ . q/ Vol. 2/ , q/Vol2~00A/ ); my $ret = system $CMD @PARAMS; die unless $ret == 0;

Edit: added q/Vol2~00A/ to script above.

bw, bliako


In reply to Re: Problem running shell command from Perl by bliako
in thread Problem running shell command from Perl by CrashBlossom

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.