简体   繁体   English

在perl中如何获取任何进程的当前目录路径?

[英]In perl how to get current directory path of any process?

In Perl, I want to get the current working directory of any process. 在Perl中,我想获取任何进程的当前工作目录。

eg We have command "pwdx" in unix which gives current working directory of a process. 例如,我们在Unix中有命令“ pwdx”,它给出了进程的当前工作目录。

I want similar "pwdx " in perl. 我想要Perl中类似的“ pwdx”。

Please let me know any Perl command which gives me current working directory of a process. 请让我知道任何提供给我当前进程工作目录的Perl命令。

Note: I am on Windows platform and not in Unix platform. 注意:我在Windows平台上,而不在Unix平台上。

Regards, 问候,

Amol 阿莫尔

You could get the details about a process (along with current working directory) with wmic or handle shell commands, as described in this question: windows batch command to determine working directory of a process 您可以使用wmichandle shell命令来获取有关进程(以及当前工作目录)的详细信息,如以下问题所述: Windows batch命令确定进程的工作目录

Then you could use that command with backticks (``) to get the output and use a regex to get the current working directory. 然后可以将该命令与反引号(``)一起使用以获取输出,并使用正则表达式获取当前的工作目录。

Note: I'm not on windows so I can't test the commands. 注意:我不在Windows上,因此无法测试命令。

您可能会看Win32 :: Process模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM