Message12143

Author adamburke
Recipients adamburke, fwierzbicki, mniklas, santa4nt, zyasoft
Date 2018-10-18.04:56:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1539838562.2.0.788709270274.issue2023@psf.upfronthosting.co.za>
In-reply-to
Content
I have hit a similar issue and have a possible cause and workaround. 

I am not clear on why yet, but it seems the normal behaviour when calling out to a Windows executable from Java is for a very limited environment to be available. The command line has to be explicitly invoked to get the context of standard commands and batch files.

Eg

>>> subprocess.call(['dir'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Adam\jython\jython\dist\Lib\subprocess.py", line 535, in call
    return Popen(*popenargs, **kwargs).wait()
  File "C:\Users\Adam\jython\jython\dist\Lib\subprocess.py", line 892, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\Adam\jython\jython\dist\Lib\subprocess.py", line 1402, in _execute_child
    raise OSError(errno.ENOENT, os.strerror(errno.ENOENT))
OSError: [Errno 2] No such file or directory
>>> subprocess.call(['cmd','/c','dir'])
 Volume in drive C is OS
 Volume Serial Number is E447-FAFD

 Directory of C:\Users\Adam\jython\jython

...

Coming from a more Unix-y background I find this quite unintuitive, but there you go.

Related stackoverflow answer here:
https://stackoverflow.com/questions/18893284/how-to-get-short-filenames-in-windows-using-java

I have been able to invoke batch files successfully on the latest Jython using cmd /c and subprocess.

I am not sure what the correct target behaviour for jython should be here. I guess CPython can be a guide to whether cmd /c should be invoked by default when calling out to subprocess under windows. That is the extent of my research for now.
History
Date User Action Args
2018-10-18 04:56:02adamburkesetmessageid: <1539838562.2.0.788709270274.issue2023@psf.upfronthosting.co.za>
2018-10-18 04:56:02adamburkesetrecipients: + adamburke, fwierzbicki, zyasoft, mniklas, santa4nt
2018-10-18 04:56:02adamburkelinkissue2023 messages
2018-10-18 04:56:01adamburkecreate