python - subprocess.call() fails on Mac and Linux -


I'm running a strange problem with the subprocess.call () function. I'm trying to use Java's Jar command subprocess.call (). Here's the code:

  imported OS import subprocess def read_war (): war_file_path = "JacobBit-WebEp-2.6.5.wire" Java_Home = OS Environment ['java' ham '] jar_path = OS Path.join (java_home, 'bin', 'jar') jar_cmd = jar_path + 'tvf' + war_file_path "to execute the command" command: "+ jar_cmd subprances. I am using Python v2.7.3 on both Windows and Linux (Oracle Enterprise Linux). In Windows 7, I see the content of the war file that I see. On Linux, however, I'm seeing 'no such file or directory' error.   $ python is a command to execute example.py: /usr/local/tools/jdk1.7.0_15/bin/jar tvf jackrabbit-webapp-2.6.5. War traceback (most Recently Call End): File "example.py", line 24, & lt; Module & gt; Read_war () file "example.py", line 23, read_war subprocess.call (jar_cmd) file "/usr/local/tools/Python-2.7.3/Lib/subprocess.py", line 493, call return popen (in * Popenargs, ** kwargs) .wait () file "/usr/local/tools/Python-2.7.3/Lib/subprocess.py", in line 679, __init__, errread, errrite) "/ usr / local / Increase child_exception in Tools / Python-2.7.3 / Lib / subprocess.py ", Line 1249, _execute_child OSError: [Error 2] No such file or directory $   

I have tried the command '/usr/local/tools/jdk1.7.0_15/bin/jar tvf jackrabbit-webapp-2.6.5.war' from the command prompt and it works fine. Therefore, nothing is wrong with the command I have tried different combinations of subprocess.call () - passing a string, passing a list etc. None of them work. Any help at all will be appreciated.

Add Shell = is true for calls. On Windows, the CreateProcess command parsing string to separate command commands and its various arguments. On Linux, you only receive string processing if you specifically tell the sub process to call the shell. Otherwise, it considers the entire string that you had handed over as a command and you do not get very far.

  subprocess.call (jar_cmd, shell = true)    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -