Forum Discussion
Kevin_Stewart
Sep 10, 2015Employee
Okay, for the sake of testing I just rebuilt the whole thing:
import re
import subprocess
p1 = subprocess.Popen([
'curl',
'-sk',
'-u',
'admin:admin',
'-H','Content-Type: application/json',
'-H','Accept: application/json',
'-X','GET',
'https://x.x.x.x/mgmt/tm/sys/connection'
],stdout=subprocess.PIPE)
p2 = subprocess.Popen([
'perl',
'-pe',
'\'s/\\n/,\n/g\''
],stdin=p1.stdout,stdout=subprocess.PIPE)
result = str(p2.communicate()).split('\\n')
for line in result:
if re.search('^[0-9].*', line) is not None:
ip = line.split(" ")
print ip[0]