我试图通过单击HTML中的按钮来运行Shell脚本。我在PHP中使用exec()运行脚本(shell脚本中包装了python脚本),但是显示了ImportError。但是,当我在终端上手动运行相同的Shell脚本时,它的工作原理就很好。
以下是文件:
index.html:
var bower_components = bower_components || 'bower_components';
require.config({
paths: {
'lib/angular': bower_components + '/angular/angular.min',
'lib/angular-animate': bower_components + '/angular-animate/angular-animate.min',
'lib/sprintf': bower_components + '/sprintf/dist/sprintf.min',
'lib/twitter-text': bower_components + '/twitter-text-js/js/twitter-text',
'lib/jsdiff': bower_components + '/jsdiff/diff',
es6: "lib/requirejs-babel/es6",
babel: "lib/requirejs-babel/babel-5.8.34.min",
'babel-plugin-module-resolver': 'lib/babel-plugin-module-resolver-standalone/index'
},
babel:{
fileExtension: ".js"
},
packages: [{
name: 'app',
location: 'build' //This directs to the file compiled by webpack
}, {
name: 'app/blogLegacy',
location: 'apps/blog-legacy'
},{
name: 'app/blog',
location: 'apps/blog-modular'
},{
page.php:
Uncaught Error: define cannot be used indirect
at module.exports (webpack:///(webpack)/buildin/amd-define.js?:2:8)
at eval (main.js:1)
at Object../app/js/app/main.js (main.js?bust=1558595950937:96)
at __webpack_require__ (main.js?bust=1558595950937:20)
at main.js?bust=1558595950937:84
at main.js?bust=1558595950937:87
module.exports @ amd-define.js:2
(anonymous) @ main.js:1
./app/js/app/main.js @ main.js?bust=1558595950937:96
__webpack_require__ @ main.js?bust=1558595950937:20
(anonymous) @ main.js?bust=1558595950937:84
(anonymous) @ main.js?bust=1558595950937:87
angular.js:38
Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.3.20/$injector/modulerr?p0=app&p1=Error%3A%20%5B%24injector%3Anomod%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.3.20%2F%24injector%2Fnomod%3Fp0%3Dapp%0A%20%20%20%20at%20http%3A%2F%2Fgo.development%2Fbower_components%2Fangular%2Fangular.min.js%3Fbust%3D1558595950937%3A6%3A417%0A%20%20%20%20at%20http%3A%2F%2Fgo.development%2Fbower_components%2Fangular%2Fangular.min.js%3Fbust%3D1558595950937%3A21%3A412%0A%20%20%20%20at%20a%20(http%3A%2F%2Fgo.development%2Fbower_components%2Fangular%2Fangular.min.js%3Fbust%3D1558595950937%3A21%3A53)%0A%20%20%20%20at%20http%3A%2F%2Fgo.development%2Fbower_components%2Fangular%2Fangular.min.js%3Fbust%3D1558595950937%3A21%3A296%0A%20%20%20%20at%20http%3A%2F%2Fgo.development%2Fbower_components%2Fangular%2Fangular.min.js%3Fbust%3D1558595950937%3A35%3A46%0A%20%20%20%20at%20r%20(http%3A%2F%2Fgo.development%2Fbower_components%2Fangular%2Fangular.min.js%3Fbust%3D1558595950937%3A7%3A322)%0A%20%20%20%20at%20g%20(http%3A%2F%2Fgo.development%2Fbower_components%2Fangular%2Fangular.min.js%3Fbust%3D1558595950937%3A34%3A399)%0A%20%20%20%20at%20cb%20(http%3A%2F%2Fgo.development%2Fbower_components%2Fangular%2Fangular.min.js%3Fbust%3D1558595950937%3A38%3A135)%0A%20%20%20%20at%20d%20(http%3A%2F%2Fgo.development%2Fbower_components%2Fangular%2Fangular.min.js%3Fbust%3D1558595950937%3A17%3A381)%0A%20%20%20%20at%20tc%20(http%3A%2F%2Fgo.development%2Fbower_components%2Fangular%2Fangular.min.js%3Fbust%3D1558595950937%3A18%3A179)
at angular.js:38
at angular.js:4154
at r (angular.js:326)
at g (angular.js:4115)
at cb (angular.js:4041)
at d (angular.js:1455)
at tc (angular.js:1476)
at Jd (angular.js:1370)
at HTMLDocument.<anonymous> (angular.js:26446)
at j (jquery.js:3148)
script.sh:
from ctypes import CDLL
from ctypes.util import find_library
tdjson_path = find_library('tdjson')
print(tdjson_path)
if tdjson_path is None:
print('can\'t find tdjson library')
quit()
tdjson = CDLL(tdjson_path)
以上脚本中的两个图像文件作为参数传递。第一个是输入文件,第二个是输出文件。
我正在使用XAMPP,当我在浏览器中运行它时,出现错误:
C:\Users\Administrador\PycharmProjects\ChatWarsBot\venv\Scripts\python.exe C:/Users/Administrador/PycharmProjects/ChatWarsBot/runme.py
Traceback (most recent call last):
D:\software\TDLib\td\tdlib\bin\tdjson.dll
File "C:/Users/Administrador/PycharmProjects/ChatWarsBot/runme.py", line 9, in <module>
tdjson = CDLL('C:/Users/Administrador/PycharmProjects/ChatWarsBot/tdjson.dll')
File "C:\Users\Administrador\AppData\Local\Programs\Python\Python37\lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
但是当我在终端中运行'./script.sh'时,我没有得到任何错误,并且得到了所需的输出。
要运行该程序,需要导入一些python模块,并且我知道我需要配置Web服务器或修复PYHTONPATH,但是我不知道该如何做,这是我的新手。 / p>
运行<form action="page.php">
<input type="submit" value="Open Script">
</form>
我有
<?php
exec('./script.sh 2>&1', $output);
print_r($output)
?>