-1

I have wrote the following code:

import os

def a():
    take = raw_input("insert: ")
    os.system("ifconfig eth0 hw ether %d") %take

a()

i get an error that unsupported operand type(s) for %: 'int' and 'str'. how can i make it work and get the string from 'take' that will be with letters, numbers and punctuation..?? (i want to insert a MAC address..).

Thannks

Anshul Goyal
  • 73,278
  • 37
  • 149
  • 186
user3091216
  • 85
  • 2
  • 3
  • 13

2 Answers2

2

In your code, raw_input returns a string so the variable take is a string.

import os

def a():
   take = raw_input("insert: ")
   os.system("ifconfig eth0 hw ether %s" % take)
Rod Xavier
  • 3,983
  • 1
  • 29
  • 41
0

Your syntax is incorrect Try below code

os.system("ifconfig eth0 hw ether %d"%take)

Use this :

import os

def a():
   take = raw_input("insert: ")
   os.system("ifconfig eth0 hw ether %s" % take)
Imran Ali Khan
  • 8,469
  • 16
  • 52
  • 77