亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

shell_exec 返回 NULL 但在 shell 中工作

shell_exec 返回 NULL 但在 shell 中工作

PHP
慕標琳琳 2022-10-14 14:38:05
在我的 php 腳本中,我通過shell_exec().(第二個腳本僅在 shell 中執行時才有效,我不知道為什么,但這在這里不重要。)這是調用另一個的主腳本:  $result = shell_exec( 'php /html/wp-content/plugins/neuhof/includes/sync/load_products.php' );  $data = json_decode($result, true);    foreach($data as $product) {        if($product['ID'] !== NULL) {            $wc_product = wc_get_product( $product['ID'] );            ?>                <tr id="<?php echo $product['Xhartid']; ?>">                    <td class="title column-title has-row-actions column-primary page-title"><strong><?php echo $wc_product->get_name(); ?></strong>                        <div class="row-actions">ID: <?php echo $product['ID']; ?> | <span class="view"> <a href="<?php echo get_permalink( $product['ID'] ); ?>" target="_blank"> Anschauen </a> </span></div>                    </td>                    <td><?php echo $product['operation']; ?></td>                    <td class="state">Warten auf WP-Cron...</td>                </tr>            <?php        } else {            ?>                <tr id="<?php echo $product['Xhartid']; ?>">                    <td class="title column-title has-row-actions column-primary page-title"><strong><?php echo $product['Xhartbez']; ?></strong>                        <div class="row-actions">Noch keine ID vergeben</div>                    </td>                    <td><?php echo $product['operation']; ?></td>                    <td class="state">Warten auf WP-Cron...</td>                </tr>            <?php        }    }腳本返回NULL,即使我嘗試exec()得到錯誤,它們也是NULL.我不知道為什么這不起作用,因為shell_exec('ls')簡單的“hello world”腳本運行良好!
查看完整描述

1 回答

?
FFIVE

TA貢獻1797條經驗 獲得超6個贊

(第二個腳本僅在 shell 中執行時才有效,我不知道為什么,但這在這里無關緊要。)

這可能是因為您提到的第二個腳本的 MSSQL 連接在您的 webserver 環境/webserver 使用的 php 配置中被阻止。

當您從 shell 運行第二個腳本時,它可能工作正常,因為它在不同的環境中工作。但是,當您在由您的網絡服務器運行的 php 腳本中使用 shell_exec 運行第二個腳本時,它會使用被阻止的相同網絡服務器環境啟動。

因此,如果您嘗試使用 shell_exec 作為“hack”來省略您的網絡服務器環境中的限制,那么它將無法正常工作。

您應該聯系您的服務器管理員來解決此問題。


查看完整回答
反對 回復 2022-10-14
  • 1 回答
  • 0 關注
  • 109 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號