I've a python program name director.py, I run the python program when my gambas program in running, so that like this
dim sOutPut as string
EXEC ["/home/bakar/director.py 1981 7 30"] TO sOutPut
but fail
gambas said no thus file or directory
why the /home/bakar/director.py exist, but gambas not found it ?
How do I get the return value from EXEC ?
Re: How do I get the return value from EXEC ?
Howdy, and welcome to the forum.
Shorter Answer:
Try:
Longer Answer:
You probably want to use Shell instead of Exec. They are similar, but different.
http://gambaswiki.org/wiki/lang/exec
http://gambaswiki.org/wiki/lang/shell
In short, Shell is "friendlier". The following code works for me:
And the results I get are: "theResult 12"
If you also want to capture the error output as well as the standard output, that is trickier. See by FFTW RunSh.module for that in the project I attached here:
https://forum.gambas.one/viewtopic.php?f=4&t=689
Hope this helps.
Ced
Shorter Answer:
Try:
EXEC ["python", "/home/bakar/director.py", "1981", "7". "30"] TO sOutPut
Longer Answer:
You probably want to use Shell instead of Exec. They are similar, but different.
http://gambaswiki.org/wiki/lang/exec
http://gambaswiki.org/wiki/lang/shell
In short, Shell is "friendlier". The following code works for me:
Dim theResult As String
' Exec ["python", Application.path & "/Hello.py", "3", "4"] To theResult
Shell "python " & Application.path & "/Hello.py 3 4" To theResult
Print "theResult", theResult
Here is Hello.py in my project directory. Note the path is explicitely needed in the shell call.Code: Select all
import sys
if len( sys.argv ) != 3 :
print "You must provide two arguments"
exit
print int( sys.argv[1] ) * int( sys.argv[2] )
If you also want to capture the error output as well as the standard output, that is trickier. See by FFTW RunSh.module for that in the project I attached here:
https://forum.gambas.one/viewtopic.php?f=4&t=689
Hope this helps.
Ced
.... and carry a big stick!
Re: How do I get the return value from EXEC ?
Thanks you!
My program can work now!
It annoy me for many days
My program can work now!
It annoy me for many days