Page 1 of 6

Catch the output of PLINK.exe (PUTTY)

Posted: 24 May 2016 16:59
by LittleBiG
Is there anybody here who has tried and managed to catch the output of plink.exe from Putty terminal emulation? It is always come back empty with runret. I want to list a folder by

Code: Select all

PLINK.EXE"" -pw password user@server.sv.com ""cd data/;ls"
from a server which runs Linux.

Re: Catch the output of PLINK.exe (PUTTY)

Posted: 24 May 2016 18:01
by highend
I have no problem with capturing the output of plink via runret...

So: Show your script
cd data/;ls
Why so complicated?

Just use:

Code: Select all

ls data

Re: Catch the output of PLINK.exe (PUTTY)

Posted: 24 May 2016 18:53
by LittleBiG
highend wrote:Just use:
Code:
ls data
This gives back also the folder, but I need only the file names. So I decided enter the folder first. Otherwise I would have to remove the folder part.

The code is simple:

Code: Select all

text runret("C:\Putty\PLINK.EXE -pw password user@server.sv.com ""cd data/;ls""");
It comes back empty. Removing the runret and put it into the dos prompt, I get the files correctly.

Re: Catch the output of PLINK.exe (PUTTY)

Posted: 24 May 2016 19:02
by highend
Can't explain, it should work

Code: Select all

text runret("D:\Users\Highend\Tools\PuTTY\plink.exe -pw <password> <username>@<ip> ""cd /media;ls""", <curpath>);
Works on a local debian server...

Re: Catch the output of PLINK.exe (PUTTY)

Posted: 25 May 2016 09:56
by LittleBiG
I am not sure if it is related, but I reach this server via an SSL gateway, so I have the Secure Application Manager on.

Re: Catch the output of PLINK.exe (PUTTY)

Posted: 25 May 2016 09:59
by highend
Secure Application Manager
Whatever that is.

When you get the output of plink in the cmd without any additional tools, tricks, whatever I don't see a reason why it shouldn't work with runret()

What happens when you start the whole thing with run instead and let the cmd window not close?

Re: Catch the output of PLINK.exe (PUTTY)

Posted: 25 May 2016 10:27
by LittleBiG

Code: Select all

run "cmd /K C:\putty\PLINK.EXE -pw password user@server.sv.com ""cd data/Archive/;ls""";
This lists the files correctly. So that's why I am :veryconfused:

Re: Catch the output of PLINK.exe (PUTTY)

Posted: 25 May 2016 10:46
by highend
Mh, as I already said: Can't explain this. I was on plink v0.63 but just upgraded to 0.67 (version 0.10.0) and it still works fine with runret...

Re: Catch the output of PLINK.exe (PUTTY)

Posted: 25 May 2016 11:33
by LittleBiG
highend wrote:Mh, as I already said: Can't explain this. I was on plink v0.63 but just upgraded to 0.67 (version 0.10.0) and it still works fine with runret...
Thanks anyway for trying to help me.

Re: Catch the output of PLINK.exe (PUTTY)

Posted: 25 May 2016 12:23
by PeterH
Strange. Tried it, using plink v0.67. Destination: local NAS.

In DOS window it works as expected.
With runret: nothing is returned.

So it seems to me that the (complete) output of plink isn't captured, somehow.

:shock: Just tried to mis-spell the userid - now, after a small timeout, runret returned the request for a password??? So *some* output of plink *is* returned! But not the result of a remote command?

Re: Catch the output of PLINK.exe (PUTTY)

Posted: 25 May 2016 12:31
by highend
Maybe plink runs a cmd on it's own (and that depends on redirection, bitness, synative folder,...)?

1st picture: ssh session on my pogoplug (an arm machine that serves as a mini server)
2nd picture: what XY returns with runret

Script:

Code: Select all

text runret("D:\Users\Highend\Tools\PuTTY\plink.exe -pw <password> <username>@<ip> ""cd /media;ls""", <curpath>);
putty.png
xy.png

Re: Catch the output of PLINK.exe (PUTTY)

Posted: 25 May 2016 13:21
by PeterH
Hm...

Using putty I see about(!) the same as you.
But I see several entries, and they are shown colored! (See below) (Files are white, directories are blue.)

In DOS I start plink *without a command*:
Some text of linux is shown - up to the command prompt,
enter cd /
enter ls
output of ls is shown, as with putty, but some (strange) formatting info is printed in front of every entry. It seems this is control for the coloring as seen with putty, but written as is instead of being executed? Might this, in any way, disturb the gathering of this text by runret?

By the way: calling plink by runret, but only with option -V, correctly returns version info.
So at least it seems "direct" output of plink is returned, while the "copied/forwarded" output from the remote system is not.

(I will be offline till this evening...)

Re: Catch the output of PLINK.exe (PUTTY)

Posted: 25 May 2016 13:30
by highend
But I see several entries, and they are shown colored! (See below) (Files are white, directories are blue.)
I'm looking below and see... nothing! :)

Sure, you probably use a different ~/.bashrc than me
In DOS I start plink *without a command*:
In DOS?
Screenshot...
Might this, in any way, disturb the gathering of this text by runret?
If you show what you're actually doing I'll test it...

Re: Catch the output of PLINK.exe (PUTTY)

Posted: 25 May 2016 13:39
by PeterH
hurry...

"See below" is *text* below: what I think could be the result, i.e your last quote

"In DOS" i.e DOS-box aka cmd-window

Re: Catch the output of PLINK.exe (PUTTY)

Posted: 25 May 2016 13:43
by highend
plink.exe *without a command*. Mh?

Just "plink.exe"? Does that start a default session from putty?

For me it just prints the command line syntax of it...