On Fri, Dec 17, 2010 at 4:17 PM, Emile van Sebille <em...@fenx.com> wrote: > On 12/17/2010 4:07 PM jtl999 said... >> >> I want to pass a variable to os.system which is dir >>>>> dir=raw_input ("Dir Please ") >>>>> os.system ("ls" + dir) >> sh: ls/: No such file or directory > > this has concatenated "ls" and dir > try with "ls "
in addition to emile's obvious suggestion, i have a few minor ones: 1) don't use a built-in function as a variable name (dir) 2) os.system() only sends off the request. if the cmd has output, you get it too. you can't capture it like you can with os.popen*() 3) you should consider using subprocess... it obsoletes all the os.*() functions cheers, -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall, (c)2007,2001 "Python Fundamentals", Prentice Hall, (c)2009 http://corepython.com wesley.j.chun :: wescpy-at-gmail.com python training and technical consulting cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor