voletri / superputty

Automatically exported from code.google.com/p/superputty
MIT License
0 stars 0 forks source link

cant read all sessions already existed in putty. #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. we cant add all putty sessions at once. need to add all sessions 1 by 1. 
if can ready all putty sessions, it will save time

What is the expected output? What do you see instead?
show already exited putty sessions in putty connection as that of in Putty 
connection manager

What version of the product are you using? On what operating system?
supreputty V1(pre 3), windows xp, putty0.6,

Original issue reported on code.google.com by anu...@gmail.com on 12 May 2010 at 5:55

GoogleCodeExporter commented 9 years ago
it appears that SuperPutty "sessions" are different from vanilla putty 
connection sessions. "import sessions" refers to importing SuperPutty sessions, 
not vanilla putty sessions.

without the ability to import my long list of existing vanilla putty 
connections, export/import of SuperPutty sessions is VERY much putting the cart 
before the horse.

Why not read the existing vanilla putty sessions from the registry?

Original comment by chiposaur on 16 Jun 2010 at 3:04

GoogleCodeExporter commented 9 years ago
Hmm.. yeah, I got to the same end. Here is what you can do: 
- create only one connection and export it so you have a sample;
- use a regular text editor (other than notepad) and make the entries on one 
line so it is easier to edit;
- find all your putty connections from the registry using:
   reg query HKCU\Software\SimonTatham\Putty\Sessions
Using the information, edit the sample.xml, creating a new line for each of 
your connections.

Note that the element <PuttySession>whatever entry</PuttySession> *has* to 
match whatever entry you have on your putty configurator so SuperPutty will use 
the settings from putty and you'll have your window as expected (otherwise, a 
black&white window will be seen)

Works for small number of connections (I have less than 10) but for large 
numbers, you have to be creative with the editing. Best is to find a text 
editor that is capable of column selection/copy/paste, which seems a feature 
remarkably under-explored.

I have attached a sample with one entry, just in case anyone is interested. You 
have to copy/past the same line over and over and modifying it.

When you have your .xml, import it back in SuperPutty (works like a charm).

-Alex

Original comment by avrl...@gmail.com on 17 Jun 2010 at 9:57

Attachments:

GoogleCodeExporter commented 9 years ago
this can be work around. and its okay to do this activity if have 5 10 
connection. I have almost 30 40 connection. and making importable xml file with 
all required details is not good efforts :( 

Original comment by anu...@gmail.com on 18 Jun 2010 at 5:24

GoogleCodeExporter commented 9 years ago
how about this for crazy. . . i had considered using this program and 
discovered i couldn't import my list of sessions... only to come around here 
that i'd been here before looking for an answer to the exact same lack of 
developer foresight. pretty discouraging.

Original comment by chiposaur on 18 Jan 2011 at 12:55

GoogleCodeExporter commented 9 years ago
Yes, this is the FIRST thing I looked for as well because I have ~100 putty 
sessions saved in the registry, I guess I can write a perl script to take the 
putty registry settings and put them in the xml format for SuperPuTTY. IF I do 
that i'll post the script here.

Original comment by Cain...@gmail.com on 1 Feb 2011 at 12:52

GoogleCodeExporter commented 9 years ago
This script will output a list of the putty sessions by ip address (sorry no 
names) into a properly formatted XML file for suuperputty import.

This script needs the following file in the same directory:

 The registry entries for putty saved as a txt file named registry.txt  

#!/usr/bin/sh -vx

echo '<?xml version="1.0" encoding="utf-8"?>
<ArrayOfSessionData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  ' > superputty-session-list.xml

grep rsa2@22 registry.txt  | awk -F : '{print $2}' | awk -F \" '{print $1}' |  
while read IP

do

echo $IP

echo '<SessionData> <SessionName>'$IP'</SessionName> <Host>'$IP'</Host> 
<Port>22</Port> <Proto>SSH</Proto> <PuttySession>myhostname 
console</PuttySession> <Username>root</Username> <LastPath>.</LastPath> 
<LastDockstate>Document</LastDockstate> 
<AutoStartSession>false</AutoStartSession> </SessionData> 

' >> superputty-session-list.xml

done

echo "</ArrayOfSessionData>" >> superputty-session-list.xml

Original comment by Cain...@gmail.com on 1 Feb 2011 at 2:26

GoogleCodeExporter commented 9 years ago
there is a new version of superputty, which can import existing putty sessions
try that.

Original comment by vikasch...@gmail.com on 5 May 2011 at 7:46

GoogleCodeExporter commented 9 years ago
to save the time of anyone following this thread, there is no new version of 
superputty. the only download available is from 2009.

vikasch...@gmail.com if you meant something else, then you should link it.

Original comment by chiposaur on 5 May 2011 at 1:51

GoogleCodeExporter commented 9 years ago
I think this is what vikasch means: https://github.com/phendryx/superputty

Original comment by THT.InfernoZeus@gmail.com on 6 May 2011 at 8:34

GoogleCodeExporter commented 9 years ago
Hereby a (non-perl) command script to export and process puTTY 0.60 registry 
sessions into a superPuTTY XML import format. Given that the new code now has 
import, this is primarily useful for transferring configurations from other 
systems.

The script is fragile (if you cancel midway, the shell session's variables get 
corrupted...) but it's tested and confirmed working with the old (pre3) and the 
new (1.0.3) superPuTTY code on both XP and Vista/windows 7.

Usual absence of any warranty applies. Lots of tricks used as you can see. I 
won't spend any more time on this one. 
Usage:
1) copy the text between the lines or use the attached txt file. save it to 
your desktop as putty_export.cmd and then double-click it, or call it from a 
command line.

The produced file will end up in your %HOMEPATH% if run from the desktop. 
change OUTPUT to suit if that's undesirable.

--- COPY BELOW THIS LINE ---
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
IF NOT DEFINED REPLACEME (
REM This IF statement works around a misinterpreation of the %20, enabling 
conversion to a space.
 SET REPLACEME=@
 CALL %0 !REPLACEME! !REPLACEME!
 EXIT /B
)

GOTO :START
REGKEY_BASE=HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\ (54 chars)

:START
SET OUTPUT=.\puttyconfig.xml
SET COUNTER=0
REM These entries are for shortcircuiting purposes.
SET IS_HostName=SERVER_IP
SET IS_Protocol=PROTOCOL
SET IS_PortNumber=PORT
SET IS_UserName=USER_NAME

SET REG=reg query HKCU\Software\SimonTatham\PuTTY\Sessions /s
CALL :PREP_OUTPUT
ECHO Beginning export and processing...
FOR /F "tokens=1,2,3*" %%a IN ('%REG%') DO (
 CALL :PARSE_VAR "%%a" "%%b" "%%c"
)
REM we write the last entry if any have been found at all.
IF DEFINED PUTTYSESSION CALL :WRITE_ENTRY
ECHO ...finished processing %COUNTER% entries.
CALL :FINISH_OUTPUT
GOTO :EOF

REM %2 has overlap with %20, which should be a space, so we remap to work 
around this.
REM %1, -%2, %3, %4
:PARSE_VAR
IF "%~1"=="" GOTO :EOF
SET V=%~1
IF "%V:~0,4%"=="HKEY" (GOTO :IF_NEWENTRY) ELSE (GOTO :IF_NEWVALUE)
:IF_NEWENTRY
    IF DEFINED PUTTYSESSION (CALL :WRITE_ENTRY) ELSE (ECHO Looking for first entry...)
    SET PUTTYSESSION=%V:~54%
    IF DEFINED PUTTYSESSION SET PUTTYSESSION=!PUTTYSESSION:@0= !
GOTO :EOF
:IF_NEWVALUE
    SET VAR_NAME=%~1
    IF NOT DEFINED IS_!VAR_NAME! GOTO :EOF
    IF NOT "%~2"=="" SET VAR_TYPE=%~2
    REM IF NOT "%~3"=="" (
        IF "%VAR_TYPE%"=="REG_DWORD" (SET /A VAR_VALUE=%~3 + 0) ELSE (SET VAR_VALUE=%~3)
    REM )
    CALL :SET_!VAR_NAME!
GOTO :EOF

:SET_HostName
SET SERVER_IP=%VAR_VALUE%
GOTO :EOF

REM we have specific adjustments as the old SuperPuTTY is  a little 
case-oversensitive for protocol types...
:SET_Protocol
IF /i "%VAR_VALUE%"=="telnet" SET PROTOCOL=Telnet
IF /i "%VAR_VALUE%"=="raw" SET PROTOCOL=Raw
IF /i "%VAR_VALUE%"=="rlogin" SET PROTOCOL=Rlogin
IF /i "%VAR_VALUE%"=="serial" SET PROTOCOL=Serial
IF /i "%VAR_VALUE%"=="ssh" SET PROTOCOL=SSH
REM SET PROTOCOL=%VAR_VALUE%
GOTO :EOF

:SET_PortNumber
SET PORT=%VAR_VALUE%
GOTO :EOF

:SET_UserName
SET USER_NAME=%VAR_VALUE%
GOTO :EOF

:PREP_OUTPUT
IF EXIST %OUTPUT% copy %OUTPUT% %OUTPUT%-old.xml
ECHO ^<?xml version="1.0" encoding="utf-8"?^>> %OUTPUT%
ECHO ^<ArrayOfSessionData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"^>>> %OUTPUT%
GOTO :EOF

:WRITE_ENTRY
SET /A COUNTER=%COUNTER% + 1
ECHO saving !PUTTYSESSION! ...
ECHO   ^<SessionData^>>> %OUTPUT%
ECHO    ^<SessionName^>%PUTTYSESSION%^</SessionName^>>> %OUTPUT%
ECHO    ^<Host^>%SERVER_IP%^</Host^>>> %OUTPUT%
ECHO    ^<Port^>%PORT%^</Port^>>> %OUTPUT%
ECHO    ^<Proto^>%PROTOCOL%^</Proto^>>> %OUTPUT%
ECHO    ^<PuttySession^>%PUTTYSESSION%^</PuttySession^>>> %OUTPUT%
IF DEFINED USER_NAME (ECHO    ^<Username^>%USER_NAME%^</Username^>>> %OUTPUT%) 
ELSE (ECHO    ^<Username^>^</Username^>>> %OUTPUT%)
ECHO    ^<LastPath^>.^</LastPath^>>> %OUTPUT%
ECHO    ^<LastDockstate^>Document^</LastDockstate^>>> %OUTPUT%
ECHO    ^<AutoStartSession^>false^</AutoStartSession^>>> %OUTPUT%
ECHO   ^</SessionData^>>> %OUTPUT%
GOTO :EOF

:FINISH_OUTPUT
ECHO ^</ArrayOfSessionData^>>> %OUTPUT%
GOTO :EOF
--- COPY ABOVE THIS LINE ---

Original comment by av.rom...@gmail.com on 9 May 2011 at 7:18

Attachments:

GoogleCodeExporter commented 9 years ago
The "File >> Copy PuTTY Sessions" Menu task works on SuperPutty 1.0.3.  Thanks!

Original comment by Kris....@gmail.com on 28 Jun 2011 at 5:17

GoogleCodeExporter commented 9 years ago
This option "File >> Copy PuTTY Sessions" is missing from the latest 1.2 
version.

Original comment by 2for1and...@gmail.com on 25 Apr 2012 at 6:53

GoogleCodeExporter commented 9 years ago
Issue 93 has been merged into this issue.

Original comment by btatey...@gmail.com on 13 May 2012 at 4:48

GoogleCodeExporter commented 9 years ago
New release will have

File -> Import Sessions -> From PuTTY settings

Sessions will be put into a folder named, ImportFromPutty.

Original comment by btatey...@gmail.com on 13 May 2012 at 4:49

GoogleCodeExporter commented 9 years ago
v1.2.0.7

Original comment by btatey...@gmail.com on 14 May 2012 at 10:33

GoogleCodeExporter commented 9 years ago
To Import your superputty sessions, the below file has all of your putty 
sessions, Copy this file 
C:\Users\<YourUserName>\Documents\SuperPuTTY\Sessions.XML to whereever you want 
to. 

Original comment by epa...@gmail.com on 29 May 2013 at 6:09