[Sidefx-houdini-list] call opparm from outside houdini

Luca Zappala luca at cinesite.co.uk
Tue May 1 10:39:30 EDT 2007


Hi Francois,

I've got a question about the pipe python implementation:
how do I pass both strings and variables into phpscript.write("""put 
variable in here""") ?
and what does bye stand for?

Also I had a look at the ref page you sent but I get an error using 
writeline (object has not attribute writeline).

Thanks
Luca



b.fx at free.fr wrote:
> Hello,
>
> Looking toward python it is like that
>
> for Sean example:
> # test set temp example
> import os, sys
> phscript = os.popen('hscript ./filename.hip','w')
> phscript.write("""opcd /obj
> set temp = `execute("opls")`
> echo $temp
> bye""")
>
> and should be
>
> # test cache_execute
> import os, sys
> phscript = os.popen('hscript ./filename.hip','w')
> phscript.write("""opparm -c /obj/geoTest cache_execute
> bye""")
>
> there is some example here:
> http://mail.python.org/pipermail/python-list/1999-November/015201.html
>
> françois
>
> Selon Ammon Riley <ammon.riley at gmail.com>:
>
>   
>> On 4/25/07, Luca Zappala <luca at cinesite.co.uk> wrote:
>>     
>>> hscript filename.hip -run "opparm -c /obj/geoTest cache_execute"
>>>       
>> In addition to the already mentioned "put your command in a file"
>> methods, I'll also point out that since hscript reads input from stdin,
>> you can just pipe your commands to it with "echo" (or whatever else
>> you like):
>>
>>     echo "opparm -c /obj/geoTest cache_execute" | hscript filename.hip
>>
>> That way, if your command isn't static, you don't have to dump out a
>> file for every single command you want to run:
>>
>>     # figure out opparm based on directory of hip
>>     if (`dirname $hipfile | grep -ic /test/` == 0) then
>>         set object = 'geoFinal'
>>     else
>>         set object = 'geoTest'
>>     endif
>>     echo "opparm -c /obj/$object cache_execute" | hscript filename.hip
>>
>> Hscript will terminate after it detects the end of input, which, in this
>> case,
>> is the single opparm command.
>>
>> If the implications of that aren't immediately obvious, beyond the example
>> above, essentially what that provides is a method for interactive control
>> over
>> hscript that you can't get by using the "commands-in-a-file" approach. If
>> you're using a more feature-rich programming language than shell scripts
>> (okay, you can do it with shell scripts, too, but it's more painful), you can
>> open a pipe to hscript. For example, in perl:
>>
>>     open HSCRIPT, "| hscript filename.hip" or die $!;
>>     print HSCRIPT "opparm -c /obj/geoTest cache_execute\n";
>>     close HSCRIPT;
>>
>> Once that pipe is open, you can feed in whatever hscript commands you
>> like, and, if you're adventurous enough to delve into interprocess
>> communication, read the responses from hscript, too, using that information
>> to figure out more commands to send to hscript.
>>
>> Cheers,
>> Ammon
>> _______________________________________________
>> Sidefx-houdini-list mailing list
>> Sidefx-houdini-list at sidefx.com
>> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>>
>>     
>
>
> _______________________________________________
> Sidefx-houdini-list mailing list
> Sidefx-houdini-list at sidefx.com
> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>
>   




More information about the Sidefx-houdini-list mailing list