以下是更新后的问题
脚本:
open (my $pipe, "| ptsetenv.sh $ProductType $Release");
print $pipe "genidasack.py -v --alignment=mips64 -a -s $WORKSPACE/dbgen/ose_signals_ADA.sdt -o $WORKSPACE/$Product/\n";
close ($pipe);
命令2:
ptsetenv.sh $ProductType $Release # Sets Environment Variables and creates a Child Shell
命令3:
genidasack.py -v --alignment=mips64 -a -s $WORKSPACE/dbgen/ose_signals_ADA.sdt -o $WORKSPACE/$Product/\n #this has to be executed on child Shell created by Command 2
目前,当我在调用第一行子shell之后在perl脚本中运行脚本,并且当从子shell中键入exit后续脚本行执行时,脚本仍保留在子shell中,这不是所需的!
这里有ptsetenv.sh的内容
envsetup.py $*
./export_env.sh
export_env.sh是基本上创建子shell的脚本
如果您需要export_env.sh
的提案,请告诉我这里有export_env.sh的内容
has_dir()
{
if [ -d $1 ]; then
return 0
else
return 1
fi
}
has_dir $DXENVROOT
if [ "$?" != "0" ]; then
echo "Directory $DXENVROOT does not exist. Exiting the script."
exit -1
fi
echo "Environment set to ${DXENVNAME} ${DXENVVERSTR}"
echo $SHELL
$SHELL
echo "Exiting ${DXENVNAME} ${DXENVVERSTR} shell"
答案 0 :(得分:0)
这将在子shell中运行一系列命令:
system("Command 1; python script; Command 2");
你也可以这样做:
system("Command 1");
system("python script");
system("Command 2");
如果命令中没有特殊的shell字符,这可以避免创建shell进程。
更新:
现在您已经澄清了python脚本启动子shell,以下是如何向它发送命令:
open (my $pipe, "| Command 1; python script");
print $pipe "Command 2\n";
close ($pipe);