Heights
Heights

Reputation: 11

os.command giving Attribute error

Hi I am trying to rum a C *.o using python 2.6.5 as follows

import os
import sys
file_type = os.command('./file_type.o %s.txt 2>&1' % file_name)

And, it gives the error message :

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'command'

Being a beginner this might be a very trivial question, I request for the direction / help.

Upvotes: 1

Views: 647

Answers (3)

zhenlohuang
zhenlohuang

Reputation: 69

os.command doesn't exist, using os.system instead.

Upvotes: 1

Andy
Andy

Reputation: 50620

os.command() doesn't exist. It looks like you are looking for os.system()

Upvotes: 1

Adam Rosenfield
Adam Rosenfield

Reputation: 400572

There is no function named command in the os module, hence the error. You probably meant to call os.system() instead.

Upvotes: 3

Related Questions