Welcome to the LimeSurvey Community Forum

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

Python Script

  • till79
  • till79's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 8 months ago #218124 by till79
Python Script was created by till79
Hallo zusammen, 

ich würde gerne, nachdem eine Umfrage gestartet wurde, ein Python Skript aufrufen und diesem die ausgefüllten Antworten übergeben. Allerdings hat das bei mir alles noch nicht richtig funktioniert.
Ich habe mir ein kleines Plugin geschrieben, was eigentlich nichts anderes macht, außer zu versuchen, die Python Datei auszuführen.
Code:
<?php
class PythonActivator extends PluginBase {
 
   protected $storage = 'DbStorage';
   static protected $description = 'PythonActivator for Limesurvey';
   static protected $name = 'PythonActivator';
 
   public function init() {
       $this->subscribe('afterSurveyComplete', 'activatePythonScript');
   }
 
   /**
   * Send the webhook on completion of a survey
   * @return array | response
   */
   public function activatePythonScript() {
       $event      = $this->getEvent();
       $surveyId   = $event->get('surveyId');
       $responseId = $event->get('responseId');
       $response   = $this->pluginManager->getAPI()->getResponse($surveyId, $responseId);
 
       $command_exec = escapeshellcmd('/AbsoluterPfad/plugins/PythonActivator/mysql.py');
       $str_output = shell_exec($command_exec);
       echo $str_output;
   }
}
?>

Das Plugin wird auch soweit erfolgreich installiert, allerdings weiß ich nicht genau wie ich das Skript starten kann, da exec ja Sicherheitstechnisch unterbunden wird. 

Aktuelle LimeSurvey Version:  Version 4.6.3+210518
Betriebssystem: Ubuntu 20.04.2 

Ich würde mich sehr über Unterstützung freuen. Im Vorraus schonmal vielen Dank, 

Till :)
 
The topic has been locked.
More
2 years 8 months ago #218128 by jelo
Replied by jelo on topic Python Script

Code:
Das Plugin wird auch soweit erfolgreich installiert, allerdings weiß ich nicht genau wie ich das Skript starten kann, da exec ja Sicherheitstechnisch unterbunden wird.

Da dürfte das LimeSurvey-Forum wenig Hilfe bieten. Die Frage lautet ja eher "Wie kann Python in deiner Hostingumgebung ausgeführt werden"? Wenn Du nicht volle Kontrolle hast, dann wird der Provider ja am ehesten wissen, ob und wie Python unterstützt wird.
Mit Exec() sollte man in Hostingumgebungen nicht rechnen. Das wird aus Sicherheitsgründen ausgeschaltet, weil zu mächtig für Missbrauch.



 

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The following user(s) said Thank You: till79
The topic has been locked.
  • till79
  • till79's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 8 months ago #218134 by till79
Replied by till79 on topic Python Script
Okay vielen Dank schonmal.

Und (ich hoffe ich bringe die Begriffe jetzt nicht durcheinander) theoretisch hosten wir die Umfrage auf einem eigenem Server. Deswegen sollte es doch möglich sein, das Python Skript auszuführen oder? :)
The topic has been locked.
More
2 years 8 months ago #218137 by jelo
Replied by jelo on topic Python Script
Exec() wird aus gutem Grund deaktiviert, weil das einen direkten Durchgriff auf den Server erlaubt. Bei mir wird kein PHP mit exec() ins Web gestellt.
Du kannst euren Webadministrator natürlich bitten, exec() in der php.ini von der Liste der deaktivierten Funktionen zu nehmen.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The following user(s) said Thank You: till79
The topic has been locked.
  • till79
  • till79's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 8 months ago #218139 by till79
Replied by till79 on topic Python Script
Ja das macht alles Sinn. Aber gibt es den keine Alternative zu exec?
The topic has been locked.
More
2 years 8 months ago #218145 by jelo
Replied by jelo on topic Python Script
Ob es Alternativen gibt, hängt vom Pythonscript ab und den erlaubten Funktionen.
Z.B. proc-open:
www.php.net/manual/en/function.proc-open.php

Thematisch ist das alles nicht im LimeSurvey-Forum angesiedelt. Ein Webserver/Webhosting oder PHP/Pythonforum dürfte hier wesentlich mehr Kompetenz und thematische Breite aufweisen.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
Moderators: Joffm

Lime-years ahead

Online-surveys for every purse and purpose