Jump to content

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


catchyid

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 :)

Link to comment
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
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...