编辑:我将此作为错误报告给Raku: qqx,shell没有正确操作报价https://github.com/rakudo/rakudo/issues/3518
其中一位管理员告诉我,Proc::Async.new应该如何运行并调用cmd.exe?https://github.com/Raku/problem-solving/issues/20
这听起来确实很像正在发生的事情,特别是“无法使用^转义空格”。部分。
如果有人想出一个变通的办法,我将不胜感激。
Windows 7和Windows 10-1909
Rakudo Star版本2019.03.1
如何在Raku中编写此命令?
fsutil usn readdata "C:/NtUtil/test 1"最大的缺陷是文件名中有一个空格,而Windows需要用双引号将它引起来。单引号崩溃。
我不能让这两个文件中的任何一个使用包含空格的文件名。fsutil可以看到两个参数,也可以看到一个名称实际包含双引号的参数:
my @Result = qqx { C:/Windows/System32/fsutil.exe usn readdata "$FileName" }.lines;
for @Result -> $Line { say $Line; };
my $proc=run( "dir", "$FileName", :out );
my @RtnStr = $proc.out.slurp-rest.lines;
for @RtnStr -> $Line { say $Line; }非常感谢,-T
编辑:将Windows 10-1909添加到框架中
编辑:使用"shell“命令没有症状变化:
@Result = shell( "C:/Windows/System32/fsutil.exe usn readdata \"$FileName\"" ).lines;
for @Result -> $Line { say $Line; };
Usage : fsutil usn readData <filename>
Eg : fsutil usn readData C:\Temp\sample.txt
@Result = shell( "C:/Windows/System32/fsutil.exe usn readdata \"$FileName\"" );
for @Result -> $Line { say $Line; };使用以下命令退出:
Proc.new(in => IO::Pipe, out => IO::Pipe, err => IO::Pipe, exitcode => 1, signal => 0, pid => 1728, command => ("C:/Windows/System32/fsutil.exe usn readdata \"C:/NtUtil/test 1\"",))注意"exitcode => 1“和最后一个带反斜杠的参数
编辑:使用单引号方法:
@Result = shell( 'C:/Windows/System32/fsutil.exe usn readdata "$FileName"' );将导致相同的错误:
Usage : fsutil usn readData <filename>
Eg : fsutil usn readData C:\Temp\sample.txt
Error: The filename, directory name, or volume label syntax is incorrect.
Proc.new(in => IO::Pipe, out => IO::Pipe, err => IO::Pipe, exitcode => 1, signal => 0, pid => 1192, command => ("C:/Windows/System32/fsutil.exe usn readdata \"\$FileName\"",))发布于 2020-02-27 14:13:42
这是shell
shell('echo "two words"'); # OUTPUT: «two words»这里和那里都是一样的。它还将为任何操作系统使用现有的通用shell。您还可以使用变量,前提是您转义指向shell的引号:
my $words = "two words"
shell("echo \"$words\"")或
shell "echo \""~ $words ~ "\""发布于 2020-03-07 17:53:55
你好,我一直在测试从Windows7到Windows10的Perl6 now Raku。我不知道这是否解决了问题,但对我来说,它是有效的:在file.rk或file.pl中写道:
shell "fsutil fsinfo驱动器和暂停“;
fsutil和pause都有效。
发布于 2020-02-27 17:38:45
也许这会有所帮助:
您可以尝试使用^转义文件路径中的空格
示例:
c:\Documents^ and^ Settings\a.bathttps://stackoverflow.com/questions/60425787
复制相似问题