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".
This 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;
}