Is it possible to run a VBScript from Ruby? I have several scripts to automate some tasks in SAP systems and I'm currently running them from Excel.
I'd like to move this to Ruby, where my other modules are in place. Is this possible, and if so, how can I accomplish this?
EDIT
More background info:
I'm using VBScripts to perform some repetitive daily tasks in certain SAP transactions. I have to carry some data to and from an SAP system. I've integrated the VBScripts to VBA and I run them via Excel where I also parse the data if necessary. I'm passing some variables (users, transactions etc.) to the scripts as well.
Now I need to move this part from the Excel to my Ruby app and trigger these VBScripts there and also collect the returned data and use them in the Ruby app.
@nmiranda: I've gone through a lot of SCN resources (also the one you mentioned), but I can't use ES, because I don't have the appropriate user level for that. The other option is to use the RFC to connect to the system and perform the tasks (https://github.com/mydoghasworms/nwrfc) but I haven't had any success yet.
So I thought I'd try to run the VBScripts from Ruby as described above. However, doing it this way would also require me to pass those variables as arguments to the VBScripts.
Example:
- Run ruby script and pass the arguments to VBScript
- Run VBScript
- Perform tasks in the system
- Leave the system
- Parse the data received from the system (not always the case)
So far I’ve searched for possibilities to do this but I haven’t found the resources mentioned in the answer below. Also my knowledge on this is very limited, hence I’ve asked here.
Now I’ve tried the suggestion below and it works:)
require 'open3'
stdin, stdout, stderr = Open3.popen3('cscript my_script.vbs')
I call the script above and this performs the tasks in the already open system.
Would this be the optimal way of doing it? And, is it possible to pass in the arguments to the VBScript?
I'm passing the argument like so:
require 'open3'
stdin, stdout, stderr = Open3.popen3('cscript my_script.vbs 0001')
And capturing them like so in my VBScript:
WScript.Arguments(0)
Is this the correct way? It seems to be working, I just need confirmation...
regards
seba