Python Shell Commands, /bin/sh: Syntax error

This semester, Derek and I have been doing some work on Postgres’ buffer management system for my CSC443 Database Systems Technology course.  Derek, wrote a nice little Python script that parses various Postgres outputs and does a bit of math on it.

However, when I tried to run his script on my machine, I got an error:

/bin/sh: Syntax error: Bad fd number

The problem was that the script relied on an os.system() call execute some shell statements. This script worked fine on the Debian systems at school, but it barfed on my Ubuntu.

A series of Google searches led me to this useful thread http://ubuntuforums.org/showthread.php?t=382548

It turns out that the command wasn’t being executed through bash, but through sh

The fix in the forum post is a bit overkill, the suggestion is to completely delete sh. I’d rather stick to the safe side and rename sh and then create the sym-link:

sudo mv /bin/sh /bin/sh.bak
sudo ln -s /bin/bash /bin/sh
This entry was posted in Linux, Tech, python and tagged , , , , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>