Re: getting stdout from "system" command

Date : Mon, 15 Oct 2007 14:49:27 -0500
To : XSI(at)Softimage.COM
From : "Bradley Gabe" <withanar(at)gmail.com>
Subject : Re: getting stdout from "system" command
AFAIK, Windows shell will always return only 0 or 1. I read that somewhere, thus it must be true ;-)
 
If you don't find a direct Windows answer, Python gives you a way out. You can run a Python script that calls os.popen(), which runs a command string and can redirect the output to a new variable:

import os

#Run command
cmd = '"rush -submit borg < C:\QueRushFile0.txt"
try:
  pipe = os.popen(cmd, 'r').read()
  
except OSError, e:
  print 'System command failed: '+cmd
#If command finishes, results should be contained in pipe
print pipe 

On 10/15/07, takita <takita(at)earthlink.net > wrote:
> Hi list...
>
> Probably a stupid question but is there a way to return the stdout from
> a running the system command?  In my case I'd like to get back the jobid
> from running the rush submit command (basically return the stdout from
> running that line to XSI), e.g. typing
>
> "rush -submit borg < C:\QueRushFile0.txt"
>
> in a windows shell gives me
>
> "set RUSH_JOBID=borg.658"
>
> which I can then use to chain another dependent job on, etc etc...  But
> running something like
>
> system("rush -submit borg < C:\\QueRushFile0.txt");
>
> from within XSI gives me back "1" or "0" (succceed or fail,
> presumably).  Any ideas?
>
> -T
>
>
>
>
>
>
> ---
> Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
> unsubscribe xsi
>

 

Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.