0

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()))

closed as off-topic by RPiAwesomeness, Videonauth, Luís de Sousa, g_p, Ron May 18 '16 at 7:34

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – RPiAwesomeness, Videonauth, Luís de Sousa, g_p, Ron
If this question can be reworded to fit the rules in the help center, please edit the question.

  • You might get better answers on StackOverflow or the Unix/Linux StackExchange, since this question isn't really specific to Ubuntu. – user533208 May 16 '16 at 20:53
1

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.

  • It works with the spaces :D thnx – M.hajer May 17 '16 at 10:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.