为什么“系统”不会在perl返回中调用?

问题描述 投票:0回答:2

新的,激进的发展。走到最后并阅读。

为x86_64-linux-thread-multi构建的perl 5,版本18,subversion 2(v5.18.2) RH6

我有一个perl脚本,它进行一个运行tcsh脚本的system()调用,但对于一个用户,它不会从该系统调用返回。代码是这样的......

#!/usr/bin/env perl
print "about to make the system call...\n";
$rv = system("tcsh aa.csh");
print "system call finished, return val = $rv\n";
exit;

和aa.csh脚本......

echo "In shell script"     
mkdir foo
source someotherscript.csh
ln -s xxx yyy
echo "In shell script, about to exit"
exit

此脚本仅对所有用户运行完成。他看到了......

about to make the system call...
In shell script
In shell script, about to exit

它只是挂起。如果我点击^ C,它就完成了..

system call finished, return val = 2

有趣的是,它打印“In shell脚本,即将退出”,下一步是“退出”,但它不会这样做,至少不是这个用户。在我看来,它之前的所有命令都是无关紧要的,因为它达到了“即将退出”的消息。似乎^ C正在中断shell脚本(它不会退出)并返回到完成脚本的perl脚本。

所以我的问题与学习为什么它挂在这个人身上有关。在他的环境中必须有一些导致问题的东西,但我不知道是什么。 “2”的返回值是什么意思?可能没什么意义,因为我用^ C打断了。

谢谢你的帮助

新发展

这与perl无关。如果aa.csh脚本只是......

exit

并且用户运行...

tcsh aa.csh

它挂了。

那是怎么回事?

主持人,如果这个帖子被删除了,我应该重新发布(因为这是完全不同的)?

linux perl tcsh
2个回答
1
投票

问题是一个损坏的.history文件。


0
投票

让他跑

which exit

tcsh提示。如果它没有说出类似的话

exit: shell built-in command

而是喜欢的东西

exit:   aliased to sleep 99999

然后你找到了你的问题。

如果exit真的是你的aa.csh脚本的最后一行,那么它是多余的,你也尝试使用最后没有调用exit的脚本版本。

© www.soinside.com 2019 - 2024. All rights reserved.