有关 Perl Expect 的帮助
我是 Perl 编程的新手。目前我的任务是理解一些代码。
我必须理解 Perl Expect 代码,在这段代码中有一行,如下所示:
我的 $exp = 新的 Expect;
$exp->spawn("su");
我的理解是,第 1 行告诉我们创建类的实例,第 2 行告诉我们创建一个子进程。
如果有人更清楚地解释我,我将非常感谢他们。
I am a newbie to Perl programming. Currently I have a task of understanding some code.
I have to understand Perl Expect code and in this piece of code a line is there, mentioned below:
my $exp = new Expect;
$exp->spawn("su");
My understanding is line 1 tells that we create an instance of the class and line 2, create a child process.
If anyone explain me more clearly I will be really thankful to them.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,让我帮助您自己:
CPAN。
您正在此处使用 Expect 模块,该模块位于 CPAN:Expect 。
从严格的语法角度来看,您所做的只是调用两个方法:
这两个方法都记录在 CPAN 中,并且它们确实执行您期望的(没有双关语意图)他们要做的事情:第一个创建一个 Expect 对象,第二个生成一个不带任何参数的进程“su”。
现在您可以使用 send 和 Expect 方法将字符串发送到进程,或者等到它要求输入。直接来自 CPAN 示例:
First of all, let me help you help yourself:
CPAN.
You are working with the Expect module here, found at CPAN:Expect.
From a strictly syntactic point of view, all you are doing is calling two methods:
Both methods are documented at CPAN, and they indeed do what you expect (no pun intended) them to do: the first one creates an Expect object, the second one spawns a process "su" without any parameters.
Now you can probably go using the send and expect methods to send a string to the process, or wait until it asks for input. Straight from the CPAN example: