Catch the output of PLINK.exe (PUTTY)

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
LittleBiG
Posts: 1848
Joined: 08 Apr 2011 12:57
Location: Win10x64

Catch the output of PLINK.exe (PUTTY)

Post 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.

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post 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
One of my scripts helped you out? Please donate via Paypal

LittleBiG
Posts: 1848
Joined: 08 Apr 2011 12:57
Location: Win10x64

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

Post 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.

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post 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...
One of my scripts helped you out? Please donate via Paypal

LittleBiG
Posts: 1848
Joined: 08 Apr 2011 12:57
Location: Win10x64

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

Post 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.

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post 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?
One of my scripts helped you out? Please donate via Paypal

LittleBiG
Posts: 1848
Joined: 08 Apr 2011 12:57
Location: Win10x64

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

Post 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:

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post 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...
One of my scripts helped you out? Please donate via Paypal

LittleBiG
Posts: 1848
Joined: 08 Apr 2011 12:57
Location: Win10x64

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

Post 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.

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

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

Post 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?

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post 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
To see the attached files, you need to log into the forum.
One of my scripts helped you out? Please donate via Paypal

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

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

Post 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...)

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post 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...
One of my scripts helped you out? Please donate via Paypal

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

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

Post 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

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post 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...
One of my scripts helped you out? Please donate via Paypal

Post Reply