I am running this command gcloud compute regions list
to fetch the list of region in my GCP. It return output like below,
NAME CPUS DISKS_GB
asia-east1 0/600 0/102400
asia-east2 0/600 0/102400
I just want to read the first column 'NAME' and store it in a list wihtout using pandas.
My code is as follow,
def get_process_cmd_output(cmd):
try:
p1 = Popen([cmd], stdout=PIPE, stderr=PIPE, shell=True)
(output, err) = p1.communicate()
return output.decode('UTF-8')
except:
return None
get_regions_list = 'gcloud compute regions list'
get_regions_response = get_process_cmd_output(get_regions_list)
print(get_regions_response)