Sign in to follow this  
Followers 0
EtoileLion

StdOutRead not returning anything

5 posts in this topic

So i'm a bit confused.

I've been reading various posts (from various years), and come up with the below script for cloning a git repo to which I have an RSA key setup...

#include <Constants.au3>
$pid = Run('git clone ssh://GITCONNECTIONINFO/' & $CmdLine[1] & ' C:\APLACETOPUTTHINGS\'& $CmdLine[1] & ' ', @ScriptDir, @SW_SHOW, $STDIN_CHILD + $STDOUT_CHILD)
Local $data
while ProcessExists($pid)
   Do
      Sleep(10)
      $data &= StdOutRead($pid)
   Until @extended or @error
   if StringInStr($data, "Enter passphrase for key") Then
      MsgBox(0,"Debug","Moo")
      StdInWrite($pid, "APASSWORD")
      $data = ""
   EndIf
   MsgBox(0,"Debug",@extended & " " & @error)
WEnd

Testing the script by pushing a Not in front of the @extended shows that i'm constantly getting back 0's in @extended.

Am i missing something obvious?

Share this post


Link to post
Share on other sites



Don't use @extended to exit the Do loop, just use @error and check to see that @error isn't set to 0. Your MsgBox will always show @error and @extended set to 0 because you're checking it after the If comparison and I'm pretty sure that never returns an error condition.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Except the prompt to enter a password isnt an error... so the Do loop runs forever?

Share this post


Link to post
Share on other sites

Then don't use @error either, check the string returned in $data for the words that are the password prompt. Either way, your original script will never do what you want it to do, so you're going to have to start debugging what is returned by the program to the script. I don't have the program you're using so I have no idea what you're seeing in the console.

StdOutRead will return a LOT of blank lines if checked in a loop until the actual text shows up, it's just how things work.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

#include <Constants.au3>
$pid = Run('git clone ssh://stuff/' & $CmdLine[1] & ' C:\place\'& $CmdLine[1] & ' ', @ScriptDir, @SW_SHOW, $STDIN_CHILD + $STDOUT_CHILD)
Local $data
while ProcessExists($pid)
      Sleep(10)
      $data &= StdOutRead($pid)
   if StringInStr($data, "Enter passphrase for key") Then
      MsgBox(0,"Debug","Moo")
      StdInWrite($pid, "morestuff")
      $data = ""
   EndIf
WEnd
MsgBox(0,"Debug",$data)

(this time without putting my password in the c&p...  :sweating: )

When run, this script hangs at the prompt, and when the window is closed (manually, because the prompt will wait forever), returns a msgbox with nothing in it. So... $data's getting nothing.

http://imgur.com/VdWtr1x

Edited by EtoileLion

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