Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

How can I run Python scripts using limesurvey?

More
4 years 11 months ago #206550 by hagerregah
I have a few python scripts I want to run. I added a few lines in Limesurvey's plugin code:
Code:
$command = escapeshellcmd('python myScript.py');
    $output = shell_exec($command);
  //$output2 = shell_exec($command);
$arr = json_decode($output);
  var_dump ($arr)


and this is the python script:
Code:
#!/usr/bin/env python

 
import json
print (json.dumps([[1,2,3], [2,4,6]]));
 

However nothing is displayed in the plugin page.

Any help?

thank you.
The topic has been locked.
More
4 years 10 months ago #206586 by holch
You are aware that Limesurvey runs on PHP, right?

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
More
4 years 10 months ago #206611 by hagerregah
I know, but when I tried the same python script ,that worked on a regular php page,on limesurvey , It did'nt display anything.
The topic has been locked.
More
4 years 10 months ago #206661 by holch

I know, but when I tried the same python script ,that worked on a regular php page,on limesurvey , It did'nt display anything.

I am not a Python expert, but you need to have some kind of python interpreter installed for the server to understand and execute it, right? It sounds weird to just paste a Python script into a PHP page and it runs. I don't think it usually works this way.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
More
4 years 10 months ago #206694 by DenisChenu

holch wrote:

I know, but when I tried the same python script ,that worked on a regular php page,on limesurvey , It did'nt display anything.

I am not a Python expert, but you need to have some kind of python interpreter installed for the server to understand and execute it, right? It sounds weird to just paste a Python script into a PHP page and it runs. I don't think it usually works this way.

Same for me, maybe we made error , but i think server parse PHP or Python. But not puyton inside PHP …

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose