我正在嘗試使用以下命令在 perl 腳本中運行 Python 腳本:
system("python3 script.py -d http:\/\/site.com --no-interaction");
qx/python3 script.py -d http:\/\/site.com --no-interaction/;
在作業系統的命令列上,Python 腳本執行,但是當我從 PHP 應用程式呼叫時,perl 作業,但 python 腳本不作業。
uj5u.com熱心網友回復:
您是否從 Perl 方面收到任何錯誤訊息?您的 PHP/Perl 腳本運行的位置可能與 script.py 所在的位置不同。嘗試使用 Python 腳本的完整路徑。還要仔細檢查 python3 是否在你的 $PATH 中。
例如:-> cat /home/me/python/script.py
print("This line will be printed.")
-> 貓 /home/me/perl/pytest.pl
#!/bin/env perl
print "From perl:\n";
system ("python3 /home/me/python/script.py");
cd /home/me/perl/
ksh
whence python3
"/usr/bin"
pytest.pl
"From perl:
This line will be printed."
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/454970.html
