开发者

How can I run and end the script() linux command from Perl?

#!/usr/bin/perl
开发者_开发知识库$sim = "multiq";
`make SCHED=$sim`;
`script > scripter`;
`echo hi`;
print pack("c", 04);
~

This script hangs when script is called. Not sure how to get the perl script to keep running.


Note that backticks (‘‘) run a command and return its output. If you're going to ignore the output, use system as in

system("make SCHED=$sim") == 0 or die "$0: make exited " . ($? >> 8)

If you want to fire-and-forget a program (that is, start it in the background without worrying about when it completes), you can use

system("script >scripter &");


You're have to run that all in one child process if you want it to all interact. See the perlipc for various ways to handle that.


you might want to look at Expect to control an interactive session


backticks (‘‘) run a command and return its output.So you can store and manipulate it further. If you want to ignore the output, use system(). Also if you want to run any process in background use & in the prefix of the process. For example you wish to start Gimp using your script simply say

system("gimp &");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜