Shoutbox

make putty session, without putty - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: make putty session, without putty (/showthread.php?tid=87541)

make putty session, without putty by Jarrod on 12-01-2008 at 09:02 AM

i'm trying to write a program to write a program to tailor putty session then launch in plink
i was using python and had

code:
for line in open(os.path.dirname(sys.argv[0])+'/sessions/base', 'rU'):
    if "ProxyPassword" in line:
        line = line.replace("ProxyPassword\\", "ProxyPassword\\" + listy[3] + chr(92)
       
                           
    if "ProxyUsername" in line:
        line = line.replace("ProxyUsername\\",  "ProxyUsername\\" + listy[2] + chr(92)

and the end of the second if statement is some invalid syntax. how do i avoid it?
( i tried using double slashes but the result was the same)
RE: make putty session, without putty by Mnjul on 12-01-2008 at 11:29 AM

Don't you think you're missing right parentheses in line.replace()? :p


RE: make putty session, without putty by Jarrod on 12-01-2008 at 11:48 AM

yep i just noticed that:P
but the main problem seems to be that python uses different line breaks to note pad and i want my file to look like this attached

but instead it looks like this:

code:
HyperlinkRegularExpression\(((https%3F|ftp):%5C/%5C/)|www%5C.)(([0-9]+%5C.[0-9]+%5C.[0-9]+%5C.[0-9]+)|localhost|([a-zA-Z0-9%5C-]+%5C.)%2A[a-zA-Z0-9%5C-]+%5C.(com|net|org|info|biz|gov|name|edu|[a-zA-Z][a-zA-Z]))(:[0-9]+)%3F((%5C/|%5C%3F)[^%20"]%2A[^%20,;%5C.:">)])%3F\
HyperlinkRegularExpressionUseDefault\1\
HyperlinkBrowser\\
HyperlinkBrowserUseDefault\1\
HyperlinkUseCtrlClick\0\
HyperlinkUnderline\1\
SerialFlowControl\1\
SerialParity\0\
SerialStopHalfbits\2\
SerialDataBits\8\
SerialSpeed\9600\
SerialLine\COM1\
ShadowBoldOffset\1\
ShadowBold\0\
WideBoldFontHeight\0\
WideBoldFontCharSet\4749836\
WideBoldFontIsBold\4627356\
WideBoldFont\\
WideFontHeight\0\
WideFontCharSet\4627372\
WideFontIsBold\4749836\
WideFont\\
BoldFontHeight\1\
BoldFontCharSet\4749832\
BoldFontIsBold\4627372\
BoldFont\\
ScrollbarOnLeft\0\
LoginShell\1\
StampUtmp\1\
BugRekey2\0\
BugPKSessID2\0\
BugRSAPad2\0\
BugDeriveKey2\0\
BugHMAC2\0\
BugRSA1\0\
BugPlainPW1\0\
BugIgnore1\0\
PortForwardings\D7070,\
RemotePortAcceptAll\0\
LocalPortAcceptAll\0\
X11AuthType\1\
X11Display\\
X11Forward\0\
BlinkText\0\
BCE\1\
LockSize\0\
EraseToScrollback\1\
ScrollOnDisp\1\
ScrollOnKey\0\
ScrollBarFullScreen\0\
ScrollBar\1\
CapsLockCyr\0\
Printer\\
UTF8Override\1\
CJKAmbigWide\0\
LineCodePage\\
Wordness224\2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2\
Wordness192\2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2\
Wordness160\1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1\
Wordness128\1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1\
Wordness96\1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1\
Wordness64\1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,2\
Wordness32\0,1,2,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1\
Wordness0\0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\
MouseOverride\1\
RectSelect\0\
MouseIsXterm\0\
PasteRTF\0\
RawCNP\0\
Colour21\255,255,255\
Colour20\187,187,187\
Colour19\85,255,255\
Colour18\0,187,187\
Colour17\255,85,255\
Colour16\187,0,187\
Colour15\85,85,255\
Colour14\0,0,187\
Colour13\255,255,85\
Colour12\187,187,0\
Colour11\85,255,85\
Colour10\0,187,0\
Colour9\255,85,85\
Colour8\187,0,0\
Colour7\85,85,85\
Colour6\0,0,0\
Colour5\0,255,0\
Colour4\0,0,0\
Colour3\85,85,85\
Colour2\0,0,0\
Colour1\255,255,255\
Colour0\187,187,187\
BoldAsColour\1\
Xterm256Colour\1\
ANSIColour\1\
TryPalette\0\
UseSystemColours\0\
FontVTMode\4\
FontQuality\0\
FontHeight\10\
FontCharSet\0\
FontIsBold\0\
Font\Courier%20New\
TermHeight\24\
TermWidth\80\
WinTitle\\
WinNameAlways\1\
DisableBidi\0\
DisableArabicShaping\0\
LFImpliesCR\0\
AutoWrapMode\1\
DECOriginMode\0\
ScrollbackLines\1000\
BellOverloadS\5000\
BellOverloadT\2000\
BellOverloadN\5\
BellOverload\1\
BellWaveFile\\
BeepInd\0\
Beep\1\
BlinkCur\0\
CurType\0\
WindowBorder\1\
SunkenEdge\0\
HideMousePtr\0\
FullScreenOnAltEnter\0\
AlwaysOnTop\0\
Answerback\PuTTY\
LocalEdit\2\
LocalEcho\2\
TelnetRet\1\
TelnetKey\0\
CtrlAltKeys\1\
ComposeKey\0\
AltOnly\0\
AltSpace\0\
AltF4\1\
WindowIcon\\
Transparency\255\
FailureReconnect\0\
WakeupReconnect\0\
TrayRestore\0\
StartTray\0\
Tray\1\
StorageType\1\
NetHackKeypad\0\
ApplicationKeypad\0\
ApplicationCursorKeys\0\
NoRemoteCharset\0\
NoDBackspace\0\
RemoteQTitleAction\1\
NoRemoteWinTitle\0\
NoAltScreen\0\
NoRemoteResize\0\
NoMouseReporting\0\
NoApplicationCursors\0\
NoApplicationKeys\0\
LinuxFunctionKeys\0\
RXVTHomeEnd\0\
BackspaceIsDelete\1\
PassiveTelnet\0\
RFCEnviron\0\
RemoteCommand\\
PublicKeyFile\\
SSH2DES\0\
SshProt\2\
SshNoShell\0\
AuthKI\1\
AuthTIS\0\
SshNoAuth\0\
RekeyBytes\1G\
RekeyTime\60\
KEX\dh-gex-sha1,dh-group14-sha1,dh-group1-sha1,WARN\
Cipher\aes,blowfish,3des,WARN,arcfour,des\
ChangeUsername\0\
AgentFwd\0\
TryAgent\1\
Compression\0\
NoPTY\0\
LocalUserName\\
UserName\\
Environment\\
ProxyTelnetCommand\connect%20%25host%20%25port%5Cn\
ProxyPassword\\
ProxyUsername\\
ProxyPort\8080\
ProxyHost\10.0.0.3\
ProxyMethod\3\
ProxyLocalhost\0\
ProxyDNS\1\
ProxyExcludeList\\
AddressFamily\0\
TerminalModes\INTR=A,QUIT=A,ERASE=A,KILL=A,EOF=A,EOL=A,EOL2=A,START=A,STOP=A,SUSP=A,DSUSP=A,REPRINT=A,WERASE=A,LNEXT=A,FLUSH=A,SWTCH=A,STATUS=A,DISCARD=A,IGNPAR=A,PARMRK=A,INPCK=A,ISTRIP=A,INLCR=A,IGNCR=A,ICRNL=A,IUCLC=A,IXON=A,IXANY=A,IXOFF=A,IMAXBEL=A,ISIG=A,ICANON=A,XCASE=A,ECHO=A,ECHOE=A,ECHOK=A,ECHONL=A,NOFLSH=A,TOSTOP=A,IEXTEN=A,ECHOCTL=A,ECHOKE=A,PENDIN=A,OPOST=A,OLCUC=A,ONLCR=A,OCRNL=A,ONOCR=A,ONLRET=A,CS7=A,CS8=A,PARENB=A,PARODD=A,\
TerminalSpeed\38400,38400\
TerminalType\xterm\
TCPKeepalives\0\
TCPNoDelay\1\
PingIntervalSecs\0\
PingInterval\0\
WarnOnClose\1\
CloseOnExit\1\
PortNumber\8080\
Protocol\ssh\
SSHLogOmitData\0\
SSHLogOmitPasswords\1\
LogFlush\1\
LogFileClash\-1\
LogType\0\
LogFileName\putty.log\
HostName\host-palace.net\
Present\1\

so any ideas on how to get python to use the putty style line breaks instead of windows ones?
thanx  also Mnjul

RE: make putty session, without putty by wj on 12-01-2008 at 10:07 PM


You probably need \n\l rather then just \n


RE: make putty session, without putty by Jarrod on 12-02-2008 at 02:48 AM

so if i go for example

code:
x = x.replace("\\n", "\\n\\l")

will that do it?

RE: make putty session, without putty by ShawnZ on 12-02-2008 at 05:56 AM

don't use \\n, use \n :p


RE: make putty session, without putty by Jarrod on 12-02-2008 at 06:21 AM

ok well for example
x = "hello\neveryone"
print x

produces:
hello
eveyone

however
x = x.replace("\n", "\n\l")
print x produces:
hello
\leveryone



RE: make putty session, without putty by ShawnZ on 12-02-2008 at 11:43 AM

also, it's \l\n :p

also, i'm pretty sure putty just needs \n


RE: make putty session, without putty by Jarrod on 12-03-2008 at 10:32 AM

quote:
Originally posted by ShawnZ
also, i'm pretty sure putty just needs \n
well why then when i open the session file in putty it just crashes, preforming an illegal operation?

and
print "hello\l\nhello"

produces:
hello\l
hello