Instead of reinventing the wheel, it is sometimes preferable to leverage scripts from other languages such as php, perl, python or ruby. This article describes how to execute scripts from these common programming language choices in Lasso 9. The code may then be incorporated procedurally within your logic, or abstracted into a method.
* “mode” is the language type, “content” is the external script or file to be executed
local(
thisroot = 'cd "'+file_forceRoot()+'";',
pre = " "
)
match(#mode) => {
case('php')
#pre = "php -r "
case('python')
#pre = "python "
case('bashScript')
#pre = " "
case('bashScriptFile')
#pre = " ./"
case('perl')
#pre = "perl "
case('ruby')
#pre = "ruby "
}
shell(#thisroot + #pre + "'" + string(#content) + "'")
The local variable #thisroot forces the command line access to be executed relative to the file being invoked.
Each language type may have specific options for invoking via command line, for instance PHP and an executable bash script file. These options are set using the match process.
The shell method is used here to simplify the execution and output handling of the os_process method.
Note: the script is executed by default with the current Lasso 9 user permissions.
Author: Jonathan Guthrie
Created: 3 May 2011
Last Modified: 3 May 2011
Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft