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?

  • hagerregah
  • hagerregah's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 5 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.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #206586 by holch
You are aware that Limesurvey runs on PHP, right?

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • hagerregah
  • hagerregah's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 5 months ago #206611 by hagerregah
Replied by hagerregah on topic How can I run Python scripts using limesurvey?
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.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 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.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #206694 by DenisChenu
Replied by DenisChenu on topic How can I run Python scripts using limesurvey?

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 service on demand , plugin development .
I don't answer to private message.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose