By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,538 Members | 1,293 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,538 IT Pros & Developers. It's quick & easy.

Invalid character in os.system call...

P: n/a
I can across some very strange behaviour last week that I'm sure wasn't
happening before.... (this is all running under Linux)

I've got two scripts.... I'm going to cut them down to the problematic
parts:

script1:

import os
os.system("script2 -f ####.tif")
script2:

import sys
print sys.argv
Now, these look fine... However, when I run 'script1', I get the following
output from script2:

['script2', '-f']

But if I run the following from the command line:
script2 -f ####.tif

I get the following output:

['script2', '-f', '####.tif']

I'm sure it never used to do this, but it nicely killed one of my scripts,
and I only fixed it by changing the line in script1 to:

os.system("script2 -f \"####.tif\"")

I don't think I should need to do that, and I'm sure I didn't used to...

So what's going on? Is os.system() taking everything after the first '#' as
a comment, or is it the way the command-line is interpreting it?

Any comments on what's causing this would be welcome - it's not a problem,
but it confused me for a while.....
Hugh Macdonald
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hugh Macdonald wrote:
os.system("script2 -f \"####.tif\"")
This looks ugly (its just my personal opinion). Because in Python its
possible to use both ' and " as string markers, you can write:

os.system('script2 -f "####.tif"')
So what's going on? Is os.system() taking everything after the
first '#' as a comment, or is it the way the command-line is
interpreting it?


Yes, just try the following on the shell-prompt:

$ echo hello # you

Thats the problem of os.system - everything goes thru the shell.

Mathias
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.