0

i want to execute following command in a python script

    java -cp lib/*:esalib.jar clldsystem.esa.ESAAnalyzer "$1" "$2"

but i'm getting a syntax error due to the '*' and ':' in the path of jar files. How else could i do it?

johnchen902
  • 9,531
  • 1
  • 27
  • 69
nish
  • 6,952
  • 18
  • 74
  • 128
  • 1
    How are you executing the python script and the java command normally? '*' expands if its run through the shell, and not all python exec options do it by default (you'll see `shell=True` in docs) – SheetJS Jun 13 '13 at 13:32
  • 1
    How are you trying to execute it? `os.system`? `subprocess.Popen`? `commands.some_api_that_should_not_be_used`? – mgilson Jun 13 '13 at 13:33

2 Answers2

0

Try to use subprocess library. I hope it helps you: Subprocess management

Ivan
  • 490
  • 1
  • 7
  • 23
0

i used the subprocess library and its working now.:) Here is how i did it

    import shlex,subprocess
    x='java -cp "lib/*:esalib.jar" clldsystem.esa.ESAAnalyzer "$1" "$2"'
    args=shlex.split(x)
    p=subprocess.Popen(args)
nish
  • 6,952
  • 18
  • 74
  • 128