Sign in to follow this  
Followers 0
edthedestroyer

(solved) PLINK error output not coming through STDoutRead()

4 posts in this topic

#1 ·  Posted (edited)

After beating my head agaist a wall for a while, I final realized that "some" output from plink (connection refused and the prompt for caching an rsa key) does not come in through stdoutread(). I see in the sciTE console, but not in stdoutread() or stderrread(). All oher output is picked up just fine. Anyone know how to read this output or where it is going? Many thanks.

I've build a little number that sends bulk commands to Cisco switches using some of the plinkwrapper, here is the area where I'm missing the output I need on the last select case.

This is what I get in the SciTE console when I run it. But it is not showing out in stdoutread().

he 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 rsa2 key fingerprint is:
ssh-rsa "baked potato"
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)

The reason I was not seeing this output is because it is error output and sent to the $sdterr_child handle which I did not create when I launched the process.

Sound confusing? Just do the following if you are having this problem. Put $STDIN_CHILD + $STDERR_MERGED in the last argument in the run function when you launch the plink process.

Example:

$_plinkhandle = Run(@comspec & " /c" & plink.exe & $Protocol & "-P "&$_plink_Port&" "& $_plinkserver,"",@SW_HIDE,$STDIN_CHILD + $STDERR_MERGED)
Edited by edthedestroyer

Share this post


Link to post
Share on other sites



You probably do an ExitLoop before having read all STDOUT information.

There really should be a test right after the STDOUTREAD() statement like:

$output = StdoutRead($_plinkhandle)
    If @error Then ExitLoop

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Let me simplify the problem.

Plink has an error/special message, stdoutread() throws an @error but nothing else, "Store key in cache? (y/n)" appears in the console but I don't know how it got there or how to read it.

Edited by edthedestroyer

Share this post


Link to post
Share on other sites

I have solved the mystery. I didn't have the $STDERR_CHILD when I used the Run function, so there was nothing to read. To simplify things, I used $STDIN_CHILD + $STDERR_MERGED so I only have to use stdoutread() to get the output.

$_plinkhandle = Run(@comspec & " /c" & plink.exe & $Protocol & "-P "&$_plink_Port&" "& $_plinkserver,"",@SW_HIDE,$STDIN_CHILD + $STDERR_MERGED)

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  
Followers 0