Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想生成一个 DOS Cmd 窗口并在新的 cmd 窗口中运行 hello.pl。
my $cmd="cd C:/run_dir && perl hello.pl"; system("start cmd.exe /k $cmd");
上面的代码将正确生成新的 dos cmd 窗口。但是,hello.pl 程序将从调用 perl 程序的窗口执行。我希望“hello.pl”从新生成的 cmd dos 窗口 C:/run_dir 运行。
谢谢!萨米
命令是
start cmd /k "cd c:\run_dir && perl hello.pl"
所以你要
system('start cmd /k "cd c:\run_dir && perl hello.pl"');