I am trying to build a command line wrapper in Python 3 for an exiting command line tool called spooky and I am having a hard time understanding some strange behavior. If I type spooky on the command line, it brings up the man page for spooky. If I enter the path to the spooky tool (/path/to/spooky) on the command line it also brings up the man page for spooky.

I can run the spooky program successfully if I place spooky in my path and then enter the required arguments like this:

$ spooky -a 50 -b .97

However, if I do not put spooky in my path and type the following the command, it will not run.

$ /path/to/spooky -a 50 -b .97

Why won't this program run when I enter the program's path and then the required arguments?

migrated from stackoverflow.com Aug 26 '11 at 17:58

This question came from our site for professional and enthusiast programmers.


In your question, does "spooky" refer to the existing command or to the python 3 wrapper you're writing yourself?

Also, you said that if you type spooky on the command line it brings up the man page. Is that correct? Just "spooky" by itself -- and not "man spooky" -- invokes a man page?


Based on what you've said, it looks like the "spooky" command is inspecting its own arguments -- including the name it was invoked as -- and complaining if the name is anything other than "spooky", which happens when you run it with the full pathname.

One simple solution would be to run the command as "spooky" from your wrapper and just make sure it's in the path.

  • spooky refers to an existing command line tool. If I type $ spooky the tool prints it's instructions. I do not need to type man spooky. – dr.bunsen Aug 26 '11 at 18:31
  • 1
    I see. So when you type "spooky" you aren't really getting a man page; the command recognized that it was called with missing or incorrect arguments and is providing you with information on how to run it correctly, which sort of looks like a man page. – John Gordon Aug 26 '11 at 18:43
  • Yes, exactly correct. I don't really understand what the problem is, but I will just add it to my path as you suggested. Thanks! – dr.bunsen Aug 26 '11 at 19:08

Any error message would be really helpful instead of "it does not run".

However, try adding


(or #!/usb/bin/python3.2 or whatever Python intepreter your system uses) as the first line of the Python script.

Also, use unix chmod command to mark the file as executable

 chmod u+x /path/to/spooky 
  • It throws this error: Error: unknown parameters! – dr.bunsen Aug 26 '11 at 15:44
  • This sounds like an error in your application internal logic. Knowing why your application behaves incorrectly would need seeing your application source code. With the current information the question is unanswerable. – Mikko Ohtamaa Aug 26 '11 at 15:46
  • Thanks for the suggestions. I tried adding the shebang prior to your suggestion. I just tried the change mode suggestion and that didn't work either. Hopefully, someone will have another suggestion. – dr.bunsen Aug 26 '11 at 15:51

It sounds like 'spooky' is doing a poor job of parsing it's arguments (why and how would depend what language spooky is written in).

A simple work around would be to change the working directory to spooky's before invoking it with os.chdir.

  • hmm, still doesn't seem to work. thanks for the suggestion. unfortunately, i don't have a choice but to use this program. – dr.bunsen Aug 26 '11 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.