Jump to content
catchyid

how to run a bash command and show result to user?

Recommended Posts

hi,

houdini 17.5, linux, python 2.7 (the version that ships with houdini :)) 

i want to launch a hython script in a shell (e.g. xterm) and show its progress to end user (basically, I need to show to artist the progress of this script, also, I want this xterm to be independent of houdini, meaning, if the user shuts down houdini, i want xterm to be running and finishe the job). I am new to python, so I checked quickly and found a way to use subprocess.Popen(['xterm'],stdout=PIPE,stderr=PIPE) which starts a shell, but could not find anyway to send the command (e.g. my hython script) to the shell (tried process.communicate, ...but nothing worked!)

I am thinking, maybe there is another ready to use gui/API in houdini to allow that? 

note: i don't want to use "run in the background" in file cache node because I need to run a script, plus i might run multiple instances of the same script (each one is doing processing different part of the hip file, it's all done on the fly, so I don't even know how many file cache node I need)

Thx :)

Share this post


Link to post
Share on other sites

 

# myscript.py
import os
import time

for f in os.listdir("."):
    time.sleep(0.1)
    print(f)

 

From Houdini:

import subprocess

# Note the -u flag for unbuffered output
cmd = "xterm -hold -e 'hython -u myscript.py'"
proc = subprocess.Popen(cmd, shell=True)

 

  • Like 1

Share this post


Link to post
Share on other sites

what can I say , thank you is not enough , really appreciate your help :)

 

thx

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×