Jump to content

CMD_Manager::execute and subprocess stream redirection


Recommended Posts

I have a node that's calling up a command line app. The app, vcc (see previous topic), depends on the Houdini environment, so to make sure that I get all of the environment variables setup properly for the subprocess, I'm calling the app up using HScript (the 'unix' command), and that is getting called from CMD_Manager::execute. Something like this:

    UT_String cmd("unix /path/to/some/app");

    OP_CommandManager* cmdMgr = OPgetDirector()->getCommandManager();
    UT_OStrStream outStr, errStr;
    cmdMgr->execute(cmd, 0, &outStr, &errStr);

I want to forward along any output from the command to my nodes. I'm capturing the stdout and forwarding it to my node with addWarning, and stderr with addError.

As long as I stay in Hscript-land, doing the redirection this way works just fine. Both stdout and stderr are captured just as expected. But I am completely unable to redirect the stderr/stdout of any hscript subprocesses. So when I execute the above command, redirection does not work.

It doesn't work with the python hscript command, either. I've tried calling this hscript:

python -c 'import sys; sys.stderr.write("this is the stderr stream"); sys.stdout.write("and this is the stdout stream")

Works fine in texptport. In fact, the unix command works fine from textport, too. But the redirection never works from the CMD_Manager.

So... any easy ways around this?

Again, having the shell environment automatically be initialized for whichever version of Houdini the shell was created from is important. If at all possible, I'd like to avoid doing any of that manually.

Thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...