Jump to content

Automate ssh plink console output problem.


 Share

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 "10.26.2.224"

Connecting to 10.26.2.224 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

connection.

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 ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Change2CUI=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Constants.au3>
if $cmdline[1] == "/?" then
    consolewrite('Type in the folowing: login password ip command')
    Exit
elseif $cmdline[0] < 4  then
        consolewrite('Parameters are missing' & @crlf & 'You have only typed ' & $cmdline[0] & ' parametrar. Type in 4')
        exit
    EndIf


$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
    Sleep(1000)
    $OUT = StdoutRead($PID)
    consolewrite($OUT)
    If StringInStr($OUT, "Store key in cache? (y/n)") Then
        StdinWrite($PID, "n" & @CRLF & @CRLF)
   
        Sleep(5000)
        ;StdinWrite($PID, "dir" & @CRLF & @CRLF)
    
        ExitLoop
    EndIf
   Next
        $OUT = StdoutRead($PID)
    consolewrite($OUT)
Edited by fusion400
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...