The below script will save your data to a file on the server you are running this script from. File name will be routeroutput. Just input the switch IP, Password and enable password in the code below and run it from your server using python.
It needs an additional module called pexpect. You can download and install it from here https://pypi.python.org/pypi/pexpect/
import pexpect
try:
switchIP= 'x.x.x.x'
switchPassword = 'your-switch-password'
switchEnable= 'your-enable-password'
commandTorun= 'The command you want to run'
telnet = 'telnet ' + switchIP
#Login to the switch
t=pexpect.spawn(telnet)
t.expect('word:')
t.sendline(switchPassword)
t.expect('#')
t.sendline(switchEnable)
t.expect('>')
#Send the command
t.sendline('commandTorun')
t.expect('>')
data = t.before
#Closing the Telnet Connection
t.sendline('exit')
t.expect('>')
t.sendline('exit')
t.expect(pexpect.EOF)
#Opening the file and writing the data to it
f = open('routeroutput', 'w')
f.write(data)
f.close()
except Exception, e:
print "The Script failed to login"
print str(e)