Jump to content

Passing Commands To Hscript On Start Up


doc

Recommended Posts

Here's my dilemma, I want to start hscript from the textport of an open houdini session.

after opening hscript I want to execute the openport command

something like:

unix "hscript myfile.hip"

unix "openport 77000"

The only problem with this is the unix command will spawn two separate processes.

I tried the following:

unix "hscript myfile.hip; openport 77000"

but his doesn't work either, rather than executing openport in hscript it's trying to execute it in

the shell.

I also tried:

unix "hscript myfile.hip\; openport 77000"

and

unix "hscript myfile.hip < openport 77000"

without success, anybody have any ideas?

many thanks

Luca

Link to comment
Share on other sites

Here's my dilemma, I want to start hscript from the textport of an open houdini session.

after opening hscript I want to execute the openport command

24158[/snapback]

As an alternative to Edward's suggestion, you could wrap the hscript launching in a simple Python script that you call instead (ie 'unix "launchHscriptAndOpenPort myFile.hip 77000"') where launchHscriptAndOpenPort would look something like (I haven't tested this, so there may be typos):

#!/bin/python
import os
import sys
file  = sys.argv[ 1 ]
port  = sys.argv[ 2 ]
houdini = os.popen( "hscript "+file, "w" )
houdini.write( "openport "+port )
os.wait()
houdini.close()

I'm also not sure if this only works on Linux or not (I seem to remember os.wait() is not a Windows-happy function). Wow, ok, so maybe this isn't the most versatile suggestion after all ;)

Link to comment
Share on other sites

As an alternative to Edward's suggestion, you could wrap the hscript launching in a simple Python script that you call instead (ie 'unix "launchHscriptAndOpenPort myFile.hip 77000"') where launchHscriptAndOpenPort would look something like (I haven't tested this, so there may be typos):

24186[/snapback]

thanks Rob,

I actually ended up using popen2 to open hscript with the optional .cmd as Ed suggested.

And then I used openport to send commands to the hscript session.

Your method looks better though. I should just be able to send commands straight to

hscript and bypass the whole openport buisness completely.

Thanks!

Luca

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...