views:

235

answers:

1

My Python utility script contains UNIX system calls such as

status, output = commands.getstatusoutput("ls -ltr")
print "Output: ", output
print "Status: ", status

Which work fine and print the output to the console but as soon as I run Maven from the same script,

status, output = commands.getstatusoutput("mvn clean install -s./../../foo/bar/settings.xml -Dportal -Dmain.dir=${PWD}/../.. -o")
print "Output: ", output
print "Status: ", status

The output is not read out like the previous regular system commands. The Maven command in quotes works fine if I simply execute it from the command line. What is the correct way to pipe Maven's output to the screen?

A: 

Are you sure that ${PWD} is properly expanded? If not, try:

status, output = commands.getstatusoutput("mvn clean install -s./../../foo/bar/settings.xml -Dportal -Dmain.dir=%s/../.. -o" % os.getcwd ())
eduffy
% os.getcwd() does the trick, thanks
Chris Tek