in reply to Problem running shell command from Perl
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Problem running shell command from Perl
by karlgoethebier (Abbot) on Jun 21, 2023 at 10:58 UTC |