I have a problem with getting some linux code output in python. I think it is because of escape characters
The command I trying to run
nmap 192.168.1.* -p T:80 --open | awk '/is up/ {print up}; {gsub (/(|)/,""); up = $NF}'
and i wanna replace that 192.168.1.* with a string variable like
network = "192.168.1.*" nmap + network + -p T:80 --open | awk '/is up/ {print up}; {gsub (/(|)/,""); up = $NF}'
Every time i try getting error. Thanks for response!
Advertisement
Answer
i found the solution like this
command = "nmap "+network+ " -p T:80 --open | awk " + r"""'/is up/ {print up}; {gsub (/(|)/,""); up = $NF}'""" output = str(os.popen(command).read()).strip() print output
thanks anyway…