[Tutor] Finding error from os.system(cmd)

Kann Vearasilp vearasilp at gmail.com
Mon May 30 14:28:49 CEST 2011


Dear all,

I tried using python to execute some external java program in my code.
My problem is the os.system(cmd) was not working properly while
executing 'java' from terminal worked just fine. I am not sure what is
wrong here. Is there a way to print out/detect error in my code for
this case?

>>>>

  1 import os
  2
  3 def create_image():
  4     path = os.path.abspath('tmp/medusa')
  5     medusa = os.path.abspath('mirnaworkbench/Medusa/Medusa.jar')
  6     cmd = str('java -cp ' + medusa + '
medusa.batchoperations.BatchOperations ' + path)
  7     os.system(cmd)

>>>>

Thanks,

Kann


More information about the Tutor mailing list