admin管理员组文章数量:1134247
I am trying to run A python Script as mentioned in the following link..
Running a python script within wordpress
But I am still getting the message "permission denied".
I am trying to run A python Script as mentioned in the following link..
Running a python script within wordpress
But I am still getting the message "permission denied".
Share Improve this question asked Nov 25, 2020 at 5:32 shekhar singhalshekhar singhal 111 bronze badge 3- Does your script have the 'x' executable permission set for the user your web server is running as? (However it might be better to call the python interpreter explicitly, rather than just running the .py script directly, else you've really written a 'run arbitrary command' shortcode not a python shortcode.) – Rup Commented Nov 25, 2020 at 9:16
- yes. it is having permission.. – shekhar singhal Commented Nov 30, 2020 at 8:22
- OK, then you're going to have to work out where the 'permission denied' is coming from then. I don't think you've given us enough information to help you. – Rup Commented Nov 30, 2020 at 8:24
1 Answer
Reset to default 1This issue of permission denied is resolved.. Permission was already given but I have added 'env python' in the popen function.. Now the code is running as expected..
add_shortcode( 'run_test_py', 'test_py' );
function test_py( $attributes )
{
$data = shortcode_atts(
[
'file' => 'test.py'
],
$attributes
);
$handle = popen('env python '. __DIR__ . '/' . $data['file'] . ' 2>&1', 'r' );
$read = '';
while ( ! feof( $handle ) )
{
$read .= fread( $handle, 2096 );
}
pclose( $handle );
return $read;
}
本文标签: pluginsRun Python Script on WordPress Website
版权声明:本文标题:plugins - Run Python Script on WordPress Website 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736793220a1953176.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论