Hello Monks,

I am running strawberry perl 5.30 under windows 11.

I am trying to use fsutil to create an 8dot3 name for a directory name which includes unicode characters. The command is:

fsutil file setShortName "C:/Users/James/Music/國語&#25079 +;念老歌 Vol. 2" "Vol2~00A"

FYI, the characters are Chinese - not displayed correctly here for some reason. Anyway, when I enter the command directly into a command shell, it creates the 8dot3 name as desired. But if I try to run the command in a perl program using backticks, it does not work.

Here is my program:

use strict; use warnings; use utf8; use open ':std', ':encoding(UTF-8)'; use Win32::Unicode; use Win32::Unicode::Dir; use Win32::Unicode::File; use Win32::Unicode::Console; use Win32::Console; Win32::Console::OutputCP(65001); # code page for Unicode (UTF-8) my $cmd = "fsutil file setShortName \"C:/Users/James/Music/國&#3 +5486;懷念老歌 Vol. 2\" \"Vol2~00A\""; my $trans = `$cmd`; print "CMD: $cmd\nTRANS: \"$trans\"";

The output is:

CMD: fsutil file setShortName "C:/Users/James/Music/國語&# +25079;念老歌 Vol. 2" "Vol2~00A" TRANS: "Error: The system cannot find the file specified.

Can anyone help me understand why I an getting this result, and what I can change to fix it?

Thanks


In reply to 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.