Jump to content
Sign in to follow this  

Automate ssh plink console output problem.

Recommended Posts


I have a problem i have managed to automate the process so it says no to store

key and then continue so that the command is executed.

But when it's time to execute the command autoit seems to loose the pipe and i get

the error "Unable to write to standard output: The pipe is being closed."

So nothing is written out but if i run plink itself there is no problem the commands

output is visible in the console window.

Is it possible to fix this problem so i can get ahold of the output?

#AutoIt3Wrapper_Change2CUI=y also does not seems to work i have to use aut2exe to make

it a console app.

Looking up host ""

Connecting to port 22

Server version: SSH-2.0-1.07

We claim version: SSH-2.0-PuTTY_Release_0.60

Using SSH protocol version 2

Doing Diffie-Hellman group exchange

Doing Diffie-Hellman key exchange with hash SHA-1

The server's host key is not cached in the registry. You

have no guarantee that the server is the computer you

think it is.

The server's dss key fingerprint is:

ssh-dss 1024 39:e3:11:d8:00:ed:f8:b3:cf:b8:ef:88:de:44:1e:99

If you trust this host, enter "y" to add the key to

PuTTY's cache and carry on connecting.

If you want to carry on connecting just once, without

adding the key to the cache, enter "n".

If you do not trust this host, press Return to abandon the


Store key in cache? (y/n) Host key fingerprint is:

ssh-dss 1024 39:e3:11:d8:00:ed:f8:b3:cf:b8:ef:88:de:44:1e:99

Initialised AES-256 SDCTR client->server encryption

Initialised HMAC-SHA1 client->server MAC algorithm

Initialised AES-256 SDCTR server->client encryption

Initialised HMAC-SHA1 server->client MAC algorithm

C:\>Using username "******".

Sent password

Access granted

Opened channel for session

Started a shell/command

Sent EOF message

Unable to write to standard output: The pipe is being closed.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Constants.au3>
if $cmdline[1] == "/?" then
    consolewrite('Type in the folowing: login password ip command')
elseif $cmdline[0] < 4  then
        consolewrite('Parameters are missing' & @crlf & 'You have only typed ' & $cmdline[0] & ' parametrar. Type in 4')

$PID = Run("c:\plink.exe -v -l " & $CMDLINE[1] & " -pw " & $CMDLINE[2] & " " & $CMDLINE[3] & " " & $CMDLINE[4], "", "", $STDIN_CHILD + $STDOUT_CHILD)

For $n = 1 To 5
    $OUT = StdoutRead($PID)
    If StringInStr($OUT, "Store key in cache? (y/n)") Then
        StdinWrite($PID, "n" & @CRLF & @CRLF)
        ;StdinWrite($PID, "dir" & @CRLF & @CRLF)
        $OUT = StdoutRead($PID)
Edited by fusion400

Share this post

Link to post
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

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.