How do i get data send back to an Perl Skript (or Python)


#1

I have a probleme, i want to use DHTMLX but our server language is Perl and i don’t know how to connet it with an event of a button (just for example). It use print to creat the side, but how can i get the data from the website back into the Perlskript? In the future we will use Python for the server, but there are also no documents for Python and the server connection… Does it work with Ajax? (if it does, how?) I hope you have a solution for my problem.


#2

You can use REST mode of dataprocessor.
In such case you can use any REST framework for data saving.

docs.dhtmlx.com/dataprocessor__i … ithrestapi


#3

You can use the backtick operator or its equivalent (and prefearable, IMHO):

return1=/path/to/script.pl arg1 arg2 return2=$(/path/to/script.pl arg1 arg2)

[download]

The latter has the added advantage of allowing nested subshell invocations.

If your return value can have newlines, I’d suggest to use double quotes:

return_newlines="$(/path/to/script.pl arg1 arg2)"

[download]

And yes, you can use read as well, but you have to be extremely careful about what you want to do. Suppose you have the following script:

#!/usr/bin/perl print $_, $/ for @ARGV;

[download]

and you want to set the Python variable value to the contents of the last line:

#!/bin/bash value=0 echo “value starts from $value” ./script.pl arg1 arg2 | while read line ; do value=$line echo “value is $value” done echo “after first while, value is $value” while read line ; do value=$line echo “value is $value” done <<<"$(./script.pl arg1 arg2)" echo “finally, value is $value”

[download]

you obtain:

value starts from 0 value is arg1 value is arg2 after first while, value is 0 value is arg1 value is arg2 finally, value is arg2

[download]

Note that after the first while the variable value has not been modified. This is due to the fact that the first while cycle is being executed inside a subshell.