Re: Capturing a Return Code?

pr144 via Jython-users <[email protected]> Mon, 13 Aug 2018 19:32:24 -0400
Newsgroups gmane.comp.lang.jython.user
Message-ID <[email protected]>
The problem is I can see the powershell is executing a Windows task, but 
control never returns back to the calling Jython script..even after the 
task is complete.

So Jython is never getting to p.returncode..

Seems like it's stuck on the p.wait() line...



On 8/13/2018 6:25 PM, Jeff Allen wro
>
> ==> script.ps1 <==
> echo "Hello World!"
> Exit 1234
>
> ==> script.py <==
> import subprocess
> p = subprocess.Popen(['powershell.exe', '-File', '.\\script.ps1'])
> p.wait()
> print "exit status =", p.returncode
>
> ==============
>
> The p.wait() is important: 
> https://docs.python.org/2/library/subprocess.html?highlight=check_output#subprocess.Popen.wait
>
> Now ...
>
> PS here> java -jar "C:\Jython\2.7.1-sa\jython-standalone-2.7.1.jar" 
> script.py
> Hello World!
> exit status = 1234
>
>
> Jeff Allen
> On 13/08/2018 18:20, Peter O'Reilly via Jython-users wrote:
>> Error says,
>>   AttributeError: 'module' objects\ has no attribute 'check_output'
>>
>> I need the  \return code from this line,
>> pipe = subprocess.Popen(['powershell.exe', 
>> 'MY_SCRIPT.ps1',stdout=sys.stdout]
>>
>>
>>
>>
>> Peter
>>
>>
>
-- 
Thank you,
Peter O'Reilly

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
Jython-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jython-users