yucatan Posted October 15, 2009 Share Posted October 15, 2009 hello guys i'm using autoit to control rsync its a command line backup utility there only one problem with the reading in autoit i miss something that are standing in the cmd windows but if i read the cmd window using StdoutRead i miss some things here i shall show. this is the script i use to read the cmd window$cmd = "rsync -vrtz --delete --progress /cygdrive/c/test 127.0.0.1::asecretpwd"; -> our exe here.. $pid = Run($cmd, @ScriptDir, @SW_HIDE, "0x2") $text = "" sleep (5000) $text &= StdoutRead($pid) ConsoleWrite($text) this is what i get in autoit building file list ... done test/TomTomGO Map Western and Central Europe v720.1803 TTS incl working keygen/Western_and_Central_Europe_V720_1803/cline.dat 32768 (0%) 65536 (0%) 98304 (0%) 131072 (0%) 163840 (0%) 196608 (0%) 229376 (0%) 262144 (0%) 294912 (0%) 327680 (0%) 360448 (0%) 393216 (0%) 425984 (0%) 458752 (0%) 491520 (0%) 524288 (0%) 557056 (0%) 589824 (0%) 622592 (0%) 655360 (0%) 688128 (0%) but if u look in the cmd window i see this: look attachment. i miss the time and mb/s why is this how should i fix this? Link to comment Share on other sites More sharing options...
yucatan Posted October 16, 2009 Author Share Posted October 16, 2009 can somebody help me pleas? Link to comment Share on other sites More sharing options...
jvanegmond Posted October 16, 2009 Share Posted October 16, 2009 Don't clutter this forum with the same question: http://www.autoitscript.com/forum/index.php?showtopic=103618 Enjoy waiting for an answer now that everyone is annoyed with your spam. github.com/jvanegmond Link to comment Share on other sites More sharing options...
yucatan Posted October 16, 2009 Author Share Posted October 16, 2009 Don't clutter this forum with the same question: http://www.autoitscript.com/forum/index.php?showtopic=103618Enjoy waiting for an answer now that everyone is annoyed with your spam.its not exacly the same question this topic is much more detaild i have show many example's here and result's i dont have that in the other topic so... thats the diffence Link to comment Share on other sites More sharing options...
jvanegmond Posted October 16, 2009 Share Posted October 16, 2009 Adding detail to the other topic was not impossible. github.com/jvanegmond Link to comment Share on other sites More sharing options...
yucatan Posted October 16, 2009 Author Share Posted October 16, 2009 Adding detail to the other topic was not impossible.thats correct but i didnt get any replay's on that so i chose to make a new one. Link to comment Share on other sites More sharing options...
jvanegmond Posted October 16, 2009 Share Posted October 16, 2009 thats correct but i didnt get any replay's on that so i chose to make a new one.And so I chose not to answer... and we're back where we started. github.com/jvanegmond Link to comment Share on other sites More sharing options...
zorphnog Posted October 16, 2009 Share Posted October 16, 2009 If you read the information in the help file, you will see: StdoutRead does not block, it will return immediately. In order to get all data, it must be called in a loop. That is why you are only getting partial output. Put it in a loop and everything should work fine. $cmd = "rsync -vrtz --delete --progress /cygdrive/c/test 127.0.0.1::asecretpwd"; -> our exe here.. $pid = Run($cmd, @ScriptDir, @SW_HIDE, "0x2") $text = "" While 1 $line = StdoutRead($pid) If @error Then ExitLoop $text &= $line Wend ConsoleWrite($text) Link to comment Share on other sites More sharing options...
yucatan Posted October 19, 2009 Author Share Posted October 19, 2009 If you read the information in the help file, you will see: That is why you are only getting partial output. Put it in a loop and everything should work fine. $cmd = "rsync -vrtz --delete --progress /cygdrive/c/test 127.0.0.1::asecretpwd"; -> our exe here.. $pid = Run($cmd, @ScriptDir, @SW_HIDE, "0x2") $text = "" While 1 $line = StdoutRead($pid) If @error Then ExitLoop $text &= $line Wend ConsoleWrite($text) hmm nice this works but there is only on issue i need to see the log during the prosess so i wanne have the data in autoit if the proces is still running and if posseble the loop need to update the $var if there something happens that a couple of second later i see it in the $var is this possible? how should i do that? Link to comment Share on other sites More sharing options...
bo8ster Posted October 19, 2009 Share Posted October 19, 2009 Look at AdlibEnable. Also you can use the site output window to live feed the output using consolewrite. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
yucatan Posted October 19, 2009 Author Share Posted October 19, 2009 (edited) i'ms now using this script $cmd = "rsync -vrtz --delete --progress /cygdrive/c/test2 127.0.0.1::asecretpwd"; -> our exe here.. $pid = Run($cmd, @ScriptDir, @SW_hide, "0x2") $text = "" While ProcessExists($pid) $line = StdoutRead($pid,1) If @error Then ExitLoop $text &= $line ConsoleWrite($line) Wend this is the output i get expandcollapse popupbuilding file list ... building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done building file list ... done test2/setup.exe 32768 (0%) building file list ... done test2/setup.exe 32768 (0%) building file list ... done test2/setup.exe 32768 (0%) building file list ... done the problem i have is that i still dont see any remaining time and mb/s if u run the command in a cmd windows i DO see them u can see in the screenshot in the first post that i can see them in the screenshot but not in autoit why is that? Edited October 19, 2009 by yucatan Link to comment Share on other sites More sharing options...
bo8ster Posted October 20, 2009 Share Posted October 20, 2009 (edited) Check the STDERR stream also. This is a dos command so try treating it like one as suggested in the help file. Edited October 20, 2009 by bo8ster Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
yucatan Posted October 20, 2009 Author Share Posted October 20, 2009 Check the STDERR stream also. This is a dos command so try treating it like one as suggested in the help file. i got it fixed expandcollapse popup#Include <GuiListbox.au3> #include <WindowsConstants.au3> #include <Constants.au3> $sCmd = "rsync -vrtz --delete --progress /cygdrive/c/test2 127.0.0.1::asecretpwd" ; Test command $npid = Run($scmd, @ScriptDir, @SW_hide, "0x2") $nAutoTimeout = 10 ; Time in seconds to close window after finish $nDeskPct = 60 ; % of desktop size (if percent) ; $nHeight = 480 ; height/width of the main window (if fixed) ; $nWidth = 480 $sTitRun = "Executing process. Wait...." ; $sTitDone = "Process done" ; $sSound = @WindowsDir & "\Media\Ding.wav" ; End Sound $sButRun = "Cancel" ; Caption of "Exec" button $sButDone = "Close" ; Caption of "Close" button Opt("GUIOnEventMode", 1) if $nDeskPct > 0 Then $nHeight = @DesktopHeight * ($nDeskPct / 100) $nWidth = @DesktopWidth * ($nDeskPct / 100) EndIf If $CmdLine[0] > 0 Then $sCmd = "" For $nCmd = 1 To $CmdLine[0] $sCmd = $sCmd & " " & $CmdLine[$nCmd] Next ; MsgBox (1,"",$sCmd) EndIf ; AutoItSetOption("GUIDataSeparatorChar", Chr(13)+Chr(10)) $nForm = GUICreate($sTitRun, $nWidth, $nHeight) GUISetOnEvent($GUI_EVENT_CLOSE, "CloseForm") $nList = GUICtrlCreateList ("", 10, 10, $nWidth - 20, $nHeight - 50, $WS_BORDER + $WS_VSCROLL) GUICtrlSetFont (-1, 9, 0, 0, "Courier New") $nClose = GUICtrlCreateButton ($sButRun, $nWidth - 100, $nHeight - 40, 80, 30) GUICtrlSetOnEvent (-1, "CloseForm") GUISetState(@SW_SHOW) ;, $nForm) $PID = Run(@ComSpec & " /C " & $sCmd, ".", @SW_HIDE, $STDOUT_CHILD) ; $nPID = Run(@ComSpec & " /C _RunErrl.bat " & $sCmd, ".", @SW_HIDE, $STDOUT_CHILD) ; # Con ésto devuelve el errorlevel en _ERRL.TMP While 1 $sLine = StdoutRead($nPID) If @error Then ExitLoop ConsoleWrite($sline&@CRLF) If StringLen ($sLine) > 0 then $sLine = StringReplace ($sLine, Chr(13), "|") $sLine = StringReplace ($sLine, Chr(10), "") if StringLeft($sLine, 1)="|" Then $sLine = " " & $sLine endif GUICtrlSetData ($nList, $sLine) MsgBox(4096, "Test", $sline) ;_GUICtrlListBox_SetCurSel ($nList, _GUICtrlListBox_GetCount ($nList) - 1) EndIf Wend $sLine = " ||" GUICtrlSetData ($nList, $sLine) _GUICtrlListBox_SetCurSel ($nList, _GUICtrlListBox_GetCount ($nList) - 1) GUICtrlSetData ($nClose, $sButDone) WinSetTitle ($sTitRun, "", $sTitDone) If $sSound <> "" Then SoundPlay ($sSound) EndIf $rInfo = DllStructCreate("uint;dword") ; # LASTINPUTINFO DllStructSetData($rInfo, 1, DllStructGetSize($rInfo)); DllCall("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr($rInfo)) $nLastInput = DllStructGetData($rInfo, 2) $nTime = TimerInit() While 1 If $nAutoTimeout > 0 Then DllCall("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr($rInfo)) If DllStructGetData($rInfo, 2) <> $nLastInput Then ; Tocó una tecla $nAutoTimeout = 0 EndIf EndIf If $nAutoTimeout > 0 And TimerDiff ($nTime) > $nAutoTimeOut * 1000 Then ExitLoop EndIf Sleep (100) Wend Func CloseForm() Exit EndFunc i can use this to live see what it happeing i can let it show in a listview or use it as variable so now i can build what i want Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now