- 论坛徽章:
- 0
|
原帖由 mousejsh 于 2008-1-31 17:13 发表 ![]()
#!/usr/bin/perl
while(1){
print "please input :\n";
my $line=;
chop($line);
if ($line eq "ok"){
#system("tail /etc/passwd");
my $forks=fork();
&kan;
}
}
sub kan {
exec("gnome- ...
改成这样
- #!/usr/bin/perl
- while(1){
- print "please input :\n";
- my $line=<>;
- chop($line);
- if ($line eq "ok"){
- #system("tail /etc/passwd");
- my $forks=fork();
- die "fail to fork" unless defined $forks;
- if($forks){
- } #parent do nothing
- else{
- &kan; #let the child do the dirty work
- }
- }
- }
- sub kan {
- exec("xterm -e \"tail /etc/passwd;read one \"");
- }
复制代码
让child去exec,parent继续while循环
至于那个一闪而过是因为gnome-terminal命令已经执行完了
可以在后面加一条 read one 命令,这样只有你回车了窗口才会消失
gnome-terminal没有试验成功
不过用xterm倒是成功了,窗口停住了
[ 本帖最后由 churchmice 于 2008-1-31 19:41 编辑 ] |
|