strip newline from string
James
oscartheduck at gmail.com
Sat Apr 28 20:07:18 EDT 2007
I have a program that reads as follows:
#!/usr/bin/env python
import string
import os
def ssher():
#ssher takes a port input (if none entered, it defaults to 2024) and
def connector():
#connector checks to see if the autoconfigure file exists. If so, it uses that
#for information for where the public ssh machine exists, if not then it tries
#something sensible.
global ipAddress, username
if os.path.isfile("autoconf.txt"):
autoconfigurer = open ( 'autoconf.txt' )
ipAddress = autoconfigurer.readline()
username = autoconfigurer.readline()
autoconfigurer.close()
string.strip(ipAddress)
string.strip(username)
print "IPAddress is %s and username is %s" % (ipAddress, username)
print "using if"
else:
from getpass import getuser
ipAddress = raw_input("We're 'pitching' this connection to another
machine. What's its IP address? Remember, this is probably a public
address.")
username = getuser()
string.strip(username)
print "username is %s" % username
print "Attempting to set up the tunnel from %s as %s" % (ipAddress, username)
cmd2 = 'ssh -nNT -R 2024:localhost:2024 %s@%s' % (username, ipAddress)
os.system(cmd2)
connector()
The autoconf.txt contains two lines, which first has an ip address and
second a username. The problem I'm having is that the string.strip()
doesn't appear to be stripping the newline off the username.
Any ideas? If you need more information, just ask!
James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070428/30018a0b/attachment.html>
More information about the Python-list
mailing list