1

I'm using this command to insert a variable :

`os.system("sudo insmod /home/hajer/final_module/module.ko src_ip=" +(R1.get()))`

and it works fine, but when I add some other variables it seems not working and I don't get the variables inserted.

os.system("sudo insmod /home/hajer/final_module/module.ko src_ip=" +(R1.get())+ "delay=" +(R2.get())+ "tcp_port=" +(R3.get()))
1
  • You might get better answers on StackOverflow or the Unix/Linux StackExchange, since this question isn't really specific to Ubuntu.
    – user533208
    May 16, 2016 at 20:53

1 Answer 1

3

The best thing in these cases is just to print the string before using it so you can see if everything is correct.

command = "sudo insmod /home/hajer/final_module/module.ko src_ip=" +(R1.get())+ "delay=" +(R2.get())+ "tcp_port=" +(R3.get())
print(command)
os.system(command)

My guess is you're missing a space before the delay and tcp_port parameters.

command = "sudo insmod /home/hajer/final_module/module.ko src_ip=" +(R1.get())+ " delay=" +(R2.get())+ " tcp_port=" +(R3.get())

Then clean things up a bit:

command = "sudo insmod /home/hajer/final_module/module.ko src_ip=%s delay=%s tcp_port=%s" % (R1.get(), R2.get(), R3.get())

Also os.system is deprecated, you should use the subprocessmodule instead.

1
  • It works with the spaces :D thnx
    – Rose
    May 17, 2016 at 10:42

Not the answer you're looking for? Browse other questions tagged .