I'm a python novice and am struggling with some concepts here - any help is appreciated.
I've got a custom system tool that queries a database, and returns several lines as results to be read -- one on each line. The following python script accepts the site FQDN from raw_input and runs $path on that fqdn.
#!/usr/bin/python
import subprocess
import getpass
#get the site name.
site = raw_input("What is the name of the site?: ").strip()
#run path.
cmd = 'path '+ site;
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE);
path_output = p.stdout.read().strip().split('\n')
print path_output
Which returns results like this this:
[' fqdn = www.hcasc.info', ' account_id = 525925', ' parent_id = 525925', ' nfs = /mnt/stor7-wc2-dfw1/525925/www.hcasc.info', ' server_type = PHP5', ' ssl = False', ' host_ip = 98.129.229.186', ' cgi_hosting = False', ' test_link_ip = 98.129.229.186', ' ipv6_ip = 2001:4800:7b02:100::1600:0']
How can I get that extra whitespace out from the "nfs = etc", or just take the third column (aka awk '{print $3}') and/or assign each piece of these results from bash to separate variables for further manipulation?
Just having some trouble mounting this learning curve, your help is sincerely appreciated.