Yes, it is possible. When you use the "Tools->Run Command" menu (or create a run command in the toolbox), a dialog will be shown for setting the details. Enabling the "Insert Output" option will redirect the command output into the current editor.
I am doing quite a lot of macro development these days and the code above was very helpful in my Optimise JavaScript extension. Many thanks for pointing out RunAndNotify. I was using a slightly modified version of Run_RunEncodedCommand, but what you have above is far better.
However, I found something very strange. I am running Windows XP SP 2 and Komodo Edit, version 4.3.0, build 1077. Calling getStdout on the process handle immediately after wait(-1) returns an empty string. If I put this in window.setTimeout(…, 1) then everything seems to be working. This is not an issue for me, but may be something worth looking into.
Hi jw,
Yes, it is possible. When you use the "Tools->Run Command" menu (or create a run command in the toolbox), a dialog will be shown for setting the details. Enabling the "Insert Output" option will redirect the command output into the current editor.
Cheers,
Todd
Thanks! I saw that, but was hoping there was some trick to "create a temporary file". But this is no big deal.
Thanks a bunch!
jw
You could also do this with either a Python or JavaScript macro, something like this (JavaScript version):
createInstance(Components.interfaces.koIRunService);
var process = runSvc.RunAndNotify("ls -la" /* command */,
"/home/toddw" /* cwd */,
"" /* environment settings */,
"" /* stdin input */);
var retval = process.wait(-1); /* wait till the process is done */
if (retval == 0) {
var newView = ko.views.manager.doNewView("Text", 'editor');
newView.scimoz.text = process.getStdout();
}
var runSvc = Components.classes["@activestate.com/koRunService;1"]. createInstance(Components.interfaces.koIRunService); var process = runSvc.RunAndNotify("ls -la" /* command */, "/home/toddw" /* cwd */, "" /* environment settings */, "" /* stdin input */); var retval = process.wait(-1); /* wait till the process is done */ if (retval == 0) { var newView = ko.views.manager.doNewView("Text", 'editor'); newView.scimoz.text = process.getStdout(); }If you create a JavaScript macro in your Komodo toolbox with this code, then it should provide you with what you need.
Cheers,
Todd
I am doing quite a lot of macro development these days and the code above was very helpful in my Optimise JavaScript extension. Many thanks for pointing out RunAndNotify. I was using a slightly modified version of Run_RunEncodedCommand, but what you have above is far better.
However, I found something very strange. I am running Windows XP SP 2 and Komodo Edit, version 4.3.0, build 1077. Calling getStdout on the process handle immediately after wait(-1) returns an empty string. If I put this in window.setTimeout(…, 1) then everything seems to be working. This is not an issue for me, but may be something worth looking into.
Thanks for the update Stan, I've logged this as a bug here (note: bug was fixed for Komodo 5.0):
http://bugs.activestate.com/show_bug.cgi?id=78030
Cheers,
Todd
Wow. That's pretty cool.
Thanks a bunch!
jw