1

I am using os.system to execute a java program through a python script. I need to pass a file name to the java program as an argument. I am not able to figure out how to pass the relative file location. What should be my reference for determining the relative location. I tried to use the location of the python script as the reference but doesn't work.

asked Sep 22, 2009 at 14:55

1 Answer 1

2

See the subprocess module for all your external process invoking needs.

p = subprocess.Popen(['myjavaapp', 'afilename.txt'])

If you need to get the relative location and you aren't sure how the other command is going to take it, make it absolute.

p = subprocess.Popen(['myjavaapp', os.path.abspath('afilename.txt')])
answered Sep 22, 2009 at 14:59
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.