I am new to Python, so any pointers are highly appreciated. I am running os.system("multiple commands here") but I am unable to get the output to a variable to display later. Also I am writing CGI script.
Here is what I am trying:
I am passing the IP variable which I am taking as input from user.
os.system("/usr/local/bin/nmap %s (ip)| grep tcp | awk -F '/' '{print $1}' ")
in bash this would be like
var=$(os.system("/usr/local/bin/nmap %s (ip)| grep tcp | awk -F '/' '{print $1}' "))
echo $var.
I want to do the same in Python 3.5 to echo this out on a browser.
I tried the os.popen approach but it errors out when I pass variable to it and I need to be able to pass variable in the command.