Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Possibility to interact with putty?
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: )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.....



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.

Copy      Help
str log1.getfile("$desktop$\putty.log")
out log1
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.
Maybe this will be useful:

Get console window text

Is it possible to post an example-code i cant get it working, when i see an example i can sort it out....

str s
if(!s.GetConsoleText(0)) ret
out s

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?

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
Copy      Help
str URL=""
str LinuxIP=""
str Port="22"
str User=""
str Pass=""
str Script="c:\"
str Output="c:\GoogleURL.txt"

str cURL=
;curl -H 'Content-Type: application/json' -d '{{"longUrl": "{URL}"}'

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]

Forum Jump:

Users browsing this thread: 1 Guest(s)