Posts: 128
Threads: 48
Joined: Jan 2007
Hi there,
Anybody an idea if there is a possibility to read out a putty (putty telnet well known but for people who don't know it:
http://www.chiark.greenend.org.uk/~sgtatham/putty/ )interaction? Like i give a command to it and the output copied in a string so it can be processed further?
An example: when im logged in and give a key ls Y to putty => is it possible to capture the output and copy it in a string for example capture_putty?
Is this possible?
Any help or directions are appreciated.....
TIA
Freggel
Posts: 331
Threads: 60
Joined: May 2006
I dont know anything about this software, but I did download it and it keeps logs in a log file. If you want to put the output in a string just use getfile to get the info out of the log file.
str log1.getfile("$desktop$\putty.log")
out log1
Posts: 128
Threads: 48
Joined: Jan 2007
THX John,
I knew that but the logfile is constantly updated and will be enormous after some time, what i like is a 'real-time' read out if possible, like with the RunConsole command or something simular without closing afterwards.
Posts: 12,028
Threads: 139
Joined: Dec 2002
Maybe this will be useful:
Get console window text
Posts: 128
Threads: 48
Joined: Jan 2007
Hi,
Is it possible to post an example-code i cant get it working, when i see an example i can sort it out....
TIA
Posts: 12,028
Threads: 139
Joined: Dec 2002
str s
if(!s.GetConsoleText(0)) ret
out s
Posts: 128
Threads: 48
Joined: Jan 2007
Hi,
Tried the example you gave several months ago, but the function quits with this line:
if(!AttachConsole(_i)) ret
what does this mean? am i doing something wrong? i adapted the consolename and nothing has to be changed i think...
any suggestions?
TIA
Posts: 1,000
Threads: 253
Joined: Feb 2008
Just to update this post a bit.
Using QuickMacros to run scripts on a Linux machine and getting the output to further process.
GetConsoleText does not get text from a PuTTY window.
I've been using the putty log files.
If you open putty, you can configure as many profiles as you may need for jobs where they would all have different log files.
In the "GoogleURL" profile, C:\GoogleURL.txt has been specified as the log file, other settings to overwrite were selected.
Function
GoogleURL
str URL="http://www.quickmacros.com/forum"
str LinuxIP="xxx.xxx.x.x"
str Port="22"
str User=""
str Pass=""
str Script="c:\GoogleURL.sh"
str Output="c:\GoogleURL.txt"
str cURL=
F
;curl https://www.googleapis.com/urlshortener/v1/url -H 'Content-Type: application/json' -d '{{"longUrl": "{URL}"}'
cURL.setfile(Script)
RunConsole2(F"c:\putty.exe -load GoogleURL -ssh {User}@{LinuxIP} {Port} -pw {Pass} -m {Script}")
str Google.getfile(Output)
str pattern="''id'': ''(.*?)'',"
ARRAY(str) a
if(findrx(Google pattern 0 0 a)<0) out "does not match"; ret
str ShortURL=a[1]