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

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.


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

Get console window text
#5
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
#6
str s
if(!s.GetConsoleText(0)) ret
out s
#7
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
#8
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
Code:
Copy      Help
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]


Forum Jump:


Users browsing this thread: 1 Guest(s)