PseudoAj
PseudoAj

Reputation: 5977

Python 2.7 subprocess call method not working to run java command

I am trying to use a python script to manipulate the input files for my java program. The way I am doing it is I am generating the file name and passing it to subprocess.call() method to execute. Here is my program:

def execJava(self):
    self.thisCmd="pause"
    call(self.javaCmd,shell=True)
    call(self.pauseCmd,shell=True)

Where,

self.javaCmd = 'java -ea -esa -Xfuture -Xss64m -classpath "C:\FVSDK_9_1_1\lib\x86_64\msc_12.0-sse2_crtdll\*" -Djava.library.path="C:\FVSDK_9_1_1\lib\x86_64\msc_12.0-sse2_crtdll;C:\FVSDK_9_1_1\lib\x86_64\share" com.cognitec.jfrsdk.examples.MatchFIRAgainstGallery C:\FVSDK_9_1_1\etc\frsdk.cfg 0 .\tmp\frsdk-scratch\probe_1.fir .\tmp\test\*' 

Yes, it's a long complex java instruction but when I run it in the command prompt it works fine. Only when I pass it as a string it doesn't run and returns:

Exception in thread "main" java.lang.Error

After some exploration into the problem, I have discovered that it is due to \x, \t in the instruction, so it is executing

.\tmp\test\*

as

mp  est\*

as it replaces \t with tab space while executing. I have looked up quite a bit and didn't find any solution. Any help is much appreciated.

Upvotes: 0

Views: 299

Answers (1)

Zachary
Zachary

Reputation: 323

Use forward slashes "/" instead of back slashes "\" for your paths.

Upvotes: 1

Related Questions