0

SO I've been stuck on this problem for a while now. I have a cgi python script that needs to execute a bash script. I have the following line in my code:

os.system("/complete/path/to/executable/run_summary_page.sh " + labelName)

I've been trying to debug this for hours now and I can't find out why it doesn't execute that correctly. When I run the same exactly line from the command line it works perfectly fine. I have given correct permissions to that bash script and so on, but it still isn't working. Note, I'm forced to use python 2.2 so I'm a little restricted with the number of utilities I have available.

7
  • 2
    Are you getting any error message? Commented Jun 15, 2012 at 19:45
  • No, it seems like it runs the script fine. The code is embedded in between some html, and the html prints out without a hitch... Commented Jun 15, 2012 at 19:46
  • What does os.system return? Commented Jun 15, 2012 at 19:57
  • Can you check the return code? stat = os.system(...) Commented Jun 15, 2012 at 19:57
  • Python 2.2 was released in 2001. You should convince your organization to let you use software that's not 11 years out of date. Commented Jun 15, 2012 at 20:03

1 Answer 1

1

I don't remember all of what is and isn't there back in python 2.2, but you can try a simple alternative for calling that command and seeing what is happening:

import commands
stat, output = commands.getstatusoutput("command")

That isn't the most robust way to run commands, but its an easy way to check whats going on right now. If the stat is != 0 then it failed. You should also be able to see both stdout and stderr in the output

If the stat == 0 and there is nothing interesting in the output, then I suspect your bash script is encountering some circumstance, ending, and not really printing anything useful. Maybe it is expecting certain environment variables, and just ignoring and moving along happily when something isn't right.

Sign up to request clarification or add additional context in comments.

1 Comment

Wow, this is actually helping me a lot. So because of the fact that we are using a shared file system, the command 'mv' isn't located at /bin/mv in the server that the site is running on. What's even more annoying is that they don't give me access to code on that server, they only give me access to code on a server that has access to the shared file system. I'm going to try and poke around some more and get back to you

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.