Jump to content

Get Output from plink.exe


Recommended Posts

HI,

headline says it all.

Example:

#include <Constants.au3>
Dim $text
 $stream = Run(@comspec & ' /c plink.exe -v hugo','',@SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ; doens't work
; $stream = Run(@comspec & ' /c plink.exe -v ','',@SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ; works
; $stream = Run(@comspec & ' /c plink.exe ','',@SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) , works

While 1
    $textline = StdoutRead($stream)
    $text = $text & @CRLF & $textline
    If @error Then ExitLoop   
Wend

MsgBox(0, "STDOUT read:", $text)

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hi,

nobody using plink? Nobody any idea?

pipe to file - doesn't work.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

  • 2 months later...

I've got plink working as a call from AutoIT - and can read it's output.

First problem you have might be with the plink setup.

You also need pageant and puttygen

It's better to use ssh

plink -v hugo

isn't actually doing a lot - just getting verbose messages

'hugo' (in your case) is actually getting the PuTTY session, not the host. You need to setup ssh on your host, generate a SSH key and a passphrase for pageant. Pageant takes your passphrase (like your bank pin code) and then sends the more complex SSH key

Check that you can then give a command like

plink -ssh hugo ls

If it asks you for your username, then you need to setup your username in a PuTTY session

Dim $sPlinkFullPath = '.....\plink.exe'

RunWait($sPlinkFullPath & ' -ssh "hugo" "ls"',@SW_MAXIMIZE)

should then get you the output of the 'ls' command for the specified account in PuTTY session 'hugo'.

See the Plink/Putty documentation http://the.earth.li/~sgtatham/putty/0.58/htmldoc/

Use Run with the options discussed previously to capture the output from the plink session.

Now my problem:

I'm using an AutoIt script to call some commands on a remote computer.

The AutoIt script is itself called from another program.

The plink works ok, but I need to capture the output and get it back to the program that called the AutoIt script, i.e. a pipe. Capturing the data is ok, but I'm having problems getting it back to the calling program. Any ideas?

Link to comment
Share on other sites

Hi,

you can write it to a file or send it via TCPSend.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...