locked
Call a Ruby script from Visual Foxpro RRS feed

  • Question

  • Hello Experts

    Is it at all possible to call a ruby script from VFP with arguments? Examples are greatly appreciated

    kind regards,

    Saturday, March 5, 2016 12:55 PM

Answers

  • A ruby script is typically called per URL and with a http request.

    Then there is a direct call of Ruby (or Python or PHP) via RUNning its main ruby.exe with the script file name as parameter: RUN ruby -r "someruby.rb" with further parameters being forwarded to the rb script as its parameters. Its result would come out via StdOut, which you could also redirect to a file with >.

    A http request can be as simple as ShellExecute of a URL or DownloadToFile API calls or usage of WinINet API or OLE class XMLHttpRequest and that also is true for PHP, JSP, ASP.NET C# or anything running with a http request (doesn't matter whether XML is involved or not).

    You can get the ruby result via any of the above API functions or you may embed a WebBrowser control and use its Navigate2 method.

    So in the end yes - in very many ways. But what you need depends on what is available to you and how the ruby script responses. Is that a ruby script in the internet? Do you have the script itself only? Does it respond with HTML? Do you want to display that HTML?

    In case you only have the script you'd need a ruby install first and if you also would rather not use it directly from commandline but make a request to a webserver, another install of eg IIS or Apache would be needed and configured to support ruby scripts. Especially if the script needs anything like server variables/objects, cookies, session, that's all not available without a webserver involved.

    If you run ruby via command line call, you do what the webserver does, very briefly saying.

    Bye, Olaf.


    Olaf Doschke - TMN Systemberatung GmbH

    http://www.tmn-systemberatung.de

    Saturday, March 5, 2016 1:18 PM