php调用sqlldr失败,php system()命令调用sqlplus导致php挂起

我有一个简单的PHP脚本,它调用sqlplus sqlldr文件并将数据转储到oracle中的表中 . 我把问题缩小到我认为是我的PHP脚本挂起的原因...这是:当我从php CLI运行时,系统命令不会回到php,而是挂在sqlplus的土地上 . 当从浏览器运行时,脚本按预期执行,然后我到达打印到浏览器的最终echo命令:我现在已经完成了运行 .

system('sqlplus username/password@tnsNameOfDatabase',$out);

echo $out;

system('exit',$out);

echo $out;

echo 'I am done running now';

从已加载sqlplus的命令行运行此脚本将正确连接到数据库,我从该连接的输出如下所示:

SQL*Plus: Release 12.1.0.2.0 Production on Wed Mar 8 15:37:34 2017

Copyright (c) 1982, 2014, Oracle. All rights reserved.

Last Successful login time: Wed Mar 08 2017 15:37:18 -05:00

Connected to:

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

With the Partitioning and Oracle Label Security options

现在...问题是这导致我的PHP程序挂起,我不能再回到PHP脚本 . 如何退出sqlplus CLI以返回运行的php脚本?

SQLPLUS中的典型退出命令只是“退出”,我尝试过(如上所示)...当手动运行时,会产生以下结果:

Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

With the Partitioning and Oracle Label Security options

如何退出sqlplus并返回应该继续的脚本?任何帮助是极大的赞赏!

再次调用此sqlplus脚本的实际方法 - 从浏览器调用时工作得很好,但是从CLI调用时,它会在返回之前在此方法中挂起 .

private function loadTempData($object) {

$this->getLog()->appendLogFile('Constructed Control File: '.$object->getTempData()->getQaveLoadControl()->getFullPathFileName());

$this->getLog()->appendLogFile('Result saved in: '.$object->getTempData()->getExportFile()->getFullPathFileName());

$object->getInsertCommandFile()->appendContent('$ sqlldr '.$this->getPersistEnv()->getUserSlid().'/'.$this->getPersistEnv()->getPassword().'@'.$this->getPersistEnv()->getDatabase().' control='.$object->getTempData()->getQaveLoadControl()->getFullPathFileName().' log='.$object->getTempData()->getQaveLoadControl()->getFullPathFileName().'.log');

$this->getLog()->appendLogFile('Loading data to Temp Table');

$command = 'sqlplus '.$this->getPersistEnv()->getUserSlid().'/'.$this->getPersistEnv()->getPassword().'@'.$this->getPersistEnv()->getDatabase().' @'.$object->insertCommandFile->getFullPathFileName();

$this->getLog()->appendLogFile($command);

system($command,$output);

// this line does not make it into the log...

$this->getLog()->appendLogFile($output);

// this method does not return when run from CLI

return true;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值