0
Problem with module "subproccess" in Kali-Linux Python3
I have this code: import subprocess as sp sp.call("echo 1 > /proc/sys/net/ipv4/ip_forward") after execution I have next problem: raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'echo 1 > /proc/sys/net/ipv4/ip_forward' . BUT if I call this command in cmd line it works! I want this to work in the python script. Please help!
7 ответов
+ 1
Since its just one string you pass to the function, add the parameter: shell=True.
# like
sp.call("echo 1 > /proc....", shell=True)
+ 1
Slick ,thank you very much! It works without any errors
0
Slick, thank you, I'll check it out. But could you explain what this parameter does?
0
nope, cause i don't know. it was easily found through a google search though
Андрей Пермяков
https://www.pythonforbeginners.com/os/subprocess-for-system-administrators/
0
Slick ,well I didn't
0
search or finf it?
0
Niiice, no problem at all! Oh, and Андрей Пермяков , a warning. Keep that code to yourself. Using the shell=True parameter allows for arbiturary code to be ran in your shell wich has big potential damage to your system. (as long as it's just you, you'll be fine) Just be careful who you let around this one and I wouldn't delete anything, it WILL work haha