Jump to content

Search the Community

Showing results for tags 'stdoutread'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Location


WWW


Interests

Found 20 results

  1. Good morning, I am trying to read a Unicode utf8 string from a perl subprocess via StdoutRead. I use an AUtoIt GUI and display result in an 'Edit' control (see my code below) using 'Courier New', a font that can handle Unicode characters. I was expecting a result looking like (CMD console): ++$ chcp 65001>NUL: & perl -Mutf8 -CS -e "use 5.018; binmode STDOUT,q(:utf8); say qq(\x{03A9})" & chcp 850>NUL: Ω Instead I get someting like this (see downward the screen copy): ++$ chcp 1250>NUL: & perl -Mutf8 -CS -e "use 5.018; binmode STDOUT,q(:utf8); say qq(\x{03A9})" & chcp 850>NUL: Ω Obviously while I was expecting to receive an utf8 char, it seems to have been converted to Windows ANSI codepage 1250 (Windows default for Western/Central Europe, right ?) What am I doing wrong? Is there someone who could guide me? Here is my code and my output in the GUI. Creating and configuring the Edit control: Local $Edit1 = GUICtrlCreateEdit( "", 20, 110, 780, 500, BitOr($GUI_SS_DEFAULT_EDIT,$ES_MULTILINE,$ES_READONLY) ) GUICtrlSetData($Edit1, "This field will contain text result from external Perl command") GUICtrlSetFont($Edit1, 10, $FW_THIN, $GUI_FONTNORMAL, "Courier New") Executing Perl command (note: `-Mutf8` and `-CS` garantees that I work in utf8 and STDOUT accepts wide-characters): local $ExePath = 'perl.exe -Mutf8 -CS ' ;~ if perl in PATH, no need for full path C:\Perl\bin\perl.exe local $Params = '-e "use 5.018; use utf8; use charnames q(:full); binmode STDOUT,q(:utf8);' & _ 'say scalar localtime; say qq(\N{GREEK CAPITAL LETTER OMEGA})"' local $Cmd = $ExePath & ' ' & $Params Local $iPID = Run($Cmd, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) Reading STDOUT and displaying it into the Edit control: While 1 $sOutput &= StdoutRead($iPID) If @error Then ; Exit the loop if the process closes or StdoutRead returns an error. ExitLoop EndIf WEnd If $sOutput <> '' Then GUICtrlSetData($Edit1, $sOutput) EndIf And now, what I get on my GUI:
  2. I have a Parent Script that starts multiple, concurrent child processes. I cannot figure out how to apply the technique for using StdoutRead in the examples in a way that listens to them all simultaneously. For reference, there can be any even number of, or single, child processes and there is an 1D array, $PIDS, that stores the PIDS of all the child processes and they should be outputting to another 1D array $sOutput. Thank you for your time. Please just point me in the right direction. I'm sorry if I missed another topic that covers this.
  3. Hello, to provide an easy to use starter to capture traffic on all NICs found, I can successfully get all the interfaces of TSHARK.EXE (the command line version that's automatically installed along with wireshark) with this script: #include <AutoItConstants.au3> #include <Array.au3> $TS_WD = "C:\Program Files\Wireshark" $TS_exe = $TS_WD & "\tshark.exe" if not FileExists($TS_exe) Then MsgBox(48,"Fatal Error","No Wireshark Commandline Tool ""TSHARK.EXE"" found:" & @CRLF & _ $TS_exe) Exit EndIf $DString = "" $PIDGetIFs = Run($TS_exe & " -D", $TS_WD, @SW_HIDE, $STDERR_MERGED) While ProcessExists($PIDGetIFs) $DString &= StdoutRead($PIDGetIFs) WEnd ; MsgBox(0,"IFs",$DString) $aNICs = StringSplit($DString, @CRLF, 1) _ArrayDisplay($aNICs) $RegExIF = "^(?:\d+\. )(\\.*?})(?: \()(.*?)(\))$" ; $1 = TSHARK Interface Name, $2 = Windows Interface Name ; ... get the names to run TSHARK with the appropriate interface string When I run TSHARK.EXE using this line directly, I see a continuously growing number telling the number of packets captured so far. "C:\Program Files\Wireshark\tshark.exe" -i \Device\NPF_{AEB931E9-E5FA-4DA5-8328-D87BDF53805C} -b duration:300 -b files:600 -w "y:\TShark-Ringbuffer\LAN-Verbindung\TSHARK-Com-0317_17---LAN-Verbindung___.pcap" Using this script, I *DO* see the first output line "Capturing on 'LAN-Verbindung'", but I cannot get hold of the continuously growing number of packets captured so far. #include <AutoItConstants.au3> $WD="C:\Program Files\Wireshark" $CMD='"C:\Program Files\Wireshark\tshark.exe" -i \Device\NPF_{AEB931E9-E5FA-4DA5-8328-D87BDF53805C} -b duration:300 -b files:600 -w "y:\TShark-Ringbuffer\LAN-Verbindung\TSHARK-Com-0317_17---LAN-Verbindung___.pcap"' ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $CMD = ' & $CMD & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $PID=Run($CMD,$WD,@SW_SHOW,$stderr_merged) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $PID = ' & $PID & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $OutputAll="" While ProcessExists($PID) $output=StdoutRead($PID) $OutputAll&=$output ToolTip($OutputAll) if $output <> "" then ConsoleWrite("""" & $output & """" & @CRLF) Sleep(1000) WEnd ConsoleWrite("Process vanished" & @CRLF) This is the output of SciTE, when I let TSHARK.EXE run for a short while, the "close" it's "box" ... --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop @@ Debug(10) : $CMD = "C:\Program Files\Wireshark\tshark.exe" -i \Device\NPF_{AEB931E9-E5FA-4DA5-8328-D87BDF53805C} -b duration:300 -b files:600 -w "y:\TShark-Ringbuffer\LAN-Verbindung\TSHARK-Com-0317_17---LAN-Verbindung___.pcap" >Error code: 0 @@ Debug(13) : $PID = 10948 >Error code: 0 "Capturing on 'LAN-Verbindung' " Process vanished Howto catch the "growing-packet-number" TSHARK.EXE is writing continuously to the same "window position"??? Regards, Rudi.
  4. Hey Guys, I have a (i think) simple question, but i can't seem to get the answer though the help-files. Hope that you can help me with this issue. - I am opening a SSH Connection with the following function Func _Connect($session,$usr,$pass) $exec = @ScriptDir & "\PLINK.EXE" If Not FileExists($exec) Then _Err("PLINK.EXE Not Found!",0) $pid = Run($exec & " -load " & $session & " -l " & $usr & " -pw " & $pass, @ScriptDir, @SW_HIDE, 0x1 + 0x8) ;Run SSH.EXE If Not $pid Then _Err("Failed to connect",0) $currentpid = $pid ;$rtn = _Read($pid) ;Check for Login Success - Prompt ;MsgBox(48,"","1") ;sleep(5000) ;Wait for connection Return $pid EndFunc - This will connect to a CMS Server with a vt100 interface where a dynamic report is generated every 20 seconds. - Then i will read the contents with the following Function Func _Read($pid) $SSHREADTIMEOUT = 0 If Not $pid Then Return -1 Local $dataA Local $dataB Do $SSHREADTIMEOUT += 1 $dataB = $dataA sleep(100) $dataA &= StdOutRead($pid) If @error Then ExitLoop Until ($dataB = $dataA And $dataA And $dataB) OR $SSHREADTIMEOUT == 50 Return $dataA EndFunc This all goes correctly, but i can only read the contents once. When i try to read the contents again i get nothing. Maybe because the CMS isn't changing, but the values in the report is changing every 20 seconds. I need to somehow read al of the contents every time i perform a Read action, but how? Yes, i can use it in a While loop, but also then i get nothing or a small line of text and not the whole report. Any Idea? Thanks Guys! --Edit-- I have fixed the problem by changing the terminal session to a vt220 session. The only problem now is that i want to send the: "Data link escape" command and that is something i cannot fix,. I have tried; StdinWrite($Pid,Hex(0x10)) StdinWrite($Pid,Chr(16)) StdinWrite($Pid,{DLE}) But nothing seems to work. -- Edit-2 -- Guys, fixed that too! Forgot to add the number '5' to actually execute the assignment. So fixed it by using; StdinWrite($Pid,Chr(16)) StdinWrite($Pid,"5") Thanks for reading with me
  5. OK, the odd stuff seems to happen to me. Not sure if this belongs here or in the deployment forum. The Question: Why would the console output results from a command-line tool need to know the working dir on one system but not the other? Though in the end I solved the issue I still am not understanding why StdoutRead seems to behave differently as I describe below. Preamble: Windows 10 image deployment to two different HP workstation hardware platforms. After deployment set up some disk space using Intel RAID. I script the Intel RSTe client (Intel® Rapid Storage Technology enterprise). Same version of the RSTe client and same storage controller hardware (Intel C600+/C220+ series chipset SATA RAID controller). The only difference is in the driver - one system has 4.2.0.1136 and the other has 5.2.0.1194, but even after I update the older driver the anomaly persists. There are of course other differences - the older system has different CPUs (Xeon E5-2620 vs Xeon Silver 4108), different chipsets, different SMBIOS, etc..). Both have Nvidia Quadro cards with driver 385.90, but the older has 3x P2000 cards and the newer has 3x Quadro M4000 and a Quadro K1200. To script RAID creation and maintenance I have a function that uses StdoutRead with Intels command line client tool "rstcli64.exe". On the older system, the below call to StdoutRead fails. On the newer system, it works. This only started happening on the older hardware when I updated the Windows version 1607 image to build 14393.2189 (but the Windows image used is the same for both hardware targets). $s_DoRST = Run(@ComSpec & " /c " & $s_RSTcmd, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) But if I change it to use @ScriptDir as the working dir, it works for both systems. $s_DoRST = Run(@ComSpec & " /c " & $s_RSTcmd, @ScriptDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) The code below is the one that works on both systems (hint: the comment " ; this only deals with one device" is because I've no hardware with more than one ATAPI device to test with). $s_RSTExe = ".\rstcli64.exe" ; for production (compiled executable) ; #FUNCTION# ==================================================================================================================== ; Name ..........: GetDiskInfoFromRSTE() ; Description ...: Queries for hard disks attached to the controller ; Syntax ........: GetDiskInfoFromRSTE() ; Parameters ....: None ; Return value...: An array of attached hard disk datas from the RST command line tool without ATAPI devices such as optical drives ; =============================================================================================================================== Func _GetDiskInfoFromRSTE() Local $s_RSTcmd = $s_RSTExe & " -I -d" Local $s_DoRST, $a_RSTDisksTemp, $s_rawdata, $numDISK = 0 If $Debug <> 0 Then ConsoleWrite("Get disk info: " & $s_RSTcmd & @CRLF) ; useful during dev but cannot be used if #requireadmin $s_DoRST = Run(@ComSpec & " /c " & $s_RSTcmd, @ScriptDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($s_DoRST) $s_rawdata = StdoutRead($s_DoRST) $a_RSTDisksTemp = StringSplit($s_rawdata, @CRLF) For $i = $a_RSTDisksTemp[0] To 1 Step -1 ; since we are deleting items, we have to go backwards through the array If $a_RSTDisksTemp[$i] = "" Or $a_RSTDisksTemp[$i] = "--DISK INFORMATION--" Then _ArrayDelete($a_RSTDisksTemp, $i) EndIf Next $a_RSTDisksTemp[0] = UBound($a_RSTDisksTemp) If IsArray($a_RSTDisksTemp) Then For $j = $a_RSTDisksTemp[0] - 1 To 1 Step -1 ; we need to remove the ATAPI device(s), since we delete we have to step through in reverse If StringInStr($a_RSTDisksTemp[$j], "Disk Type: SATA") Then $numDISK = $numDISK + 1 EndIf Next For $j = $a_RSTDisksTemp[0] - 1 To 1 Step -1 ; we need to remove the ATAPI device(s), since we delete we have to step through in reverse If StringInStr($a_RSTDisksTemp[$j], "ATAPI") Then ; we have to delete the ID entry BEFORE and AFTER the ATAPI entry to remove the ATAPI device (always delete from the bottom up!). _ArrayDelete($a_RSTDisksTemp, $j + 1) ; delete entry below _ArrayDelete($a_RSTDisksTemp, $j) ; delete entry _ArrayDelete($a_RSTDisksTemp, $j - 1) ; delete entry above ExitLoop ; this only deals with one device. If there were more we would need to capture all ATAPI device ID locations into another array then delete the original array entries based on the index numbers in the new array. EndIf Next $a_RSTDisksTemp[0] = UBound($a_RSTDisksTemp) If $a_RSTDisksTemp[0] <> 1 Then If $Debug <> 0 Then ConsoleWrite("Found " & $numDISK & " disk(s) attached to controller." & @CRLF) _infoLog("_GetDiskInfoFromRSTE() found " & $numDISK & " disk(s) attached to controller.", $msgSource) Else If $Debug <> 0 Then ConsoleWrite("No disks found to be attached to controller." & @CRLF) _infoLog("No disks found to be attached to controller.", $msgSource) EndIf Else If $Debug <> 0 Then ConsoleWrite("Unable to query RAID controller. Check hardware and version of RST client software." & @CRLF) _errorLog("Unable to query RAID controller. Check hardware.", $msgSource) Exit EndIf Return $a_RSTDisksTemp EndFunc ;==>_GetDiskInfoFromRSTE
  6. Hi, I'm new. Anyways, I'm using the RunBinary.au3 script by trancexx and I want to re-direct the STDOUT of the "child process" back to the autoit script that launches it. I'm attempting to do so using named pipes. If its possible to use StdoutRead instead of namedpipes please let me know. I'm just unsure of how to provide a handle of the childs STDOUT stream to that function. Though DllCall("kernel32.dll", "ptr", "GetStdHandle", "dword", "STD_OUTPUT_HANDLE") seems to get the handle? Please excuse any foolish mistakes because I'm new to STDOUT, runbinary and namedpipes. Here's the parts of the code I'm trying to use that are relevent: ;~~~Firstly I think I need to make a pipe that's inheritable.. which I may have done wrong Local $_SECURITY_ATTRIBUTES = DllStructCreate("dword Length;" & _ "int lpSecurityDescriptor;" & _ "bool InheritHandle;") ;***Not positive if bool works correctly here? DLLStructSetData($_SECURITY_ATTRIBUTES, "Length", DllStructGetSize($_SECURITY_ATTRIBUTES)) DLLStructSetData($_SECURITY_ATTRIBUTES, "lpSecurityDescriptor", 0) ;***This sets default state; "If the value of this member is NULL, the object is assigned the default security descriptor associated with the access token of the calling process." but I'm unsure if this is what I should use DLLStructSetData($_SECURITY_ATTRIBUTES, "InheritHandle", true);***True = Inheritable(but again I'm not positive the bool works correctly?) Global $hNamedPipe = _NamedPipes_CreateNamedPipe("\\.\pipe\poopp", _;Name 2, _;Direction: 2=both ;I only need 1 direction but I'm just using this for testing 1, _;Flags: 1=no extra instances of pipe are allowed to run 0, _;Security: No ACL Security 0, _;Type: 0=byte 0, _;ReadType: 0=byte 1, _;Wait: 0=Block(wait) 1=No block(no wait) 1, _;Max Instances of pipe allowed 4096, _;out size 4096, _;in size 9000, _;timeout DllStructGetPtr($_SECURITY_ATTRIBUTES));Default=0 which wouldn't make the handle inheritable ;~~~Next I would need to set the STARTUPINFO of the process ;code used by trancexx for the _STARTUPINFO Global $tSTARTUPINFO = DllStructCreate("dword cbSize;" & _ "ptr Reserved;" & _ "ptr Desktop;" & _ "ptr Title;" & _ "dword X;" & _ "dword Y;" & _ "dword XSize;" & _ "dword YSize;" & _ "dword XCountChars;" & _ "dword YCountChars;" & _ "dword FillAttribute;" & _ "dword Flags;" & _ "word ShowWindow;" & _ "word Reserved2;" & _ "ptr Reserved2;" & _ "ptr hStdInput;" & _ "ptr hStdOutput;" & _ "ptr hStdError") ;Attempting to set the values for namedpipe redirection DllStructSetData($tSTARTUPINFO, "Flags", 0x00000100) ;***Flag = STARTF_USESTDHANDLES (I think I set it correctly?) DllStructSetData($tSTARTUPINFO, "hStdOutput", $hNamedPipe) ;***Currently setting the output handle to the SERVER end of the NamePipe I'm creating (which I'm pretty sure is wrong but idk how to use the Client End) ;~~~code used by trancexx for CreateProcess Global $aCall = DllCall("kernel32.dll", "bool", "CreateProcessW", _ "wstr", $sExeModule, _ "wstr", $sCommandLine, _ "ptr", 0, _ "ptr", 0, _ "bool", true, _ ;***changed to inherit handles (not positive I did so correctly) was int 0 before "dword", 4, _ ; CREATE_SUSPENDED ; <- this is essential "ptr", 0, _ "ptr", 0, _ "ptr", DllStructGetPtr($tSTARTUPINFO), _ "ptr", DllStructGetPtr($tPROCESS_INFORMATION)) ;~~~~~Code used in a loop to try to see if anything is being written into the pipe If _IsPressed(35, $hDLL) Then Local $pipeData = _NamedPipes_PeekNamedPipe($hNamedPipe) If @Error Then MsgBox(1,"PipeData Error",@Error & " | " & $pipeData) Else Local $r = _ArrayDisplay($pipeData) If @Error Then MsgBox(1,"Array Error",@Error & " | " & $pipeData) EndIf EndIf I'm not using this exact code cause I changed it around some for the post. I'm mainly wondering how to correctly use the client end of the name pipe? I also had some values I wasn't sure if I set correctly because I don't have experience with com objects. And It seems the process launched needs to be the child?.. Can the process started through the autoitscript can be considered the child process and the script the parent process? Guides I'm using for this: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx https://support.microsoft.com/en-us/help/190351/how-to-spawn-console-processes-with-redirected-standard-handles
  7. #include <Constants.au3> ListLetter() Func ListLetter() ;$DSK = Run("cmd", '', '', $STDIN_CHILD + $STDOUT_CHILD) $DSK = Run(@ComSpec & " /c diskpart.exe start", '', '', $STDIN_CHILD + $STDOUT_CHILD) ConsoleWrite('$DSK - '& $DSK&' - Error - '& @error &' - '&@MSEC&@CRLF) Sleep(2000) $Read = StdoutRead($DSK, True, False) ConsoleWrite(' - '& @error &' - '&@MSEC&@CRLF) ConsoleWrite('StdoutRead ' &$Read&' - '&@MSEC&@CRLF) EndFunc ;==>ListLetter So, this works with normal console "cmd" why does it error with diskpart? how can i make it read from diskpart?
  8. Hi, Background: i have a number of instances of the same application that I want to automate in parallel. Unfortunately, I cannot completely automate these instances in the background. So, from time to time these instances need to have the focus so that I can interact with the controls via “send” directly. Each of the application instances is controlled by a au3 complied script. Each script (called with a parameter) manages the automation of the respective application-instance. Each of the (complied) script (instances) is called by a (central) front end with a gui. The front end controls if the “focus” is available to do the “send” and “mouseclick” modifications. The central front end either allows a child to have the focus or prevents it to get the focus (in which case the child will wait and checks again). The code for the front end is included. Apologies for the lengthy explanation. #RequireAdmin #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <GUIEdit.au3> #include <ScrollBarConstants.au3> #include <Array.au3> Global Const $APF_ALLOWMULTILINE = 1 Global Const $APF_RIGHTALIGN = 6 Global Const $APF_RIGHTALIGNCOL = 2 Global Const $APF_RIGHTALIGNDATA = 4 Global Const $APF_PRINTROWNUM = 8 Global Const $APF_DEFAULT = $APF_PRINTROWNUM Global $PID[9], $FocusAvailable = True, $previousEditMsg Global $PID_waiting[0][2], $logfile $logfile = "D:\MultiInstance\Logfiles\FrontEnd.txt" If FileExists($logfile) Then FileDelete($logfile) #Region ### START Koda GUI section ### Form= $hGui_1 = GUICreate("Instanzenmanager", 493, 1226, 1807, 93) $grpInst1 = GUICtrlCreateGroup(" 1 ", 8, 8, 233, 121) $btnPause01 = GUICtrlCreateCheckbox("Pause", 16, 64, 50, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $tbnStop01 = GUICtrlCreateCheckbox("Stop", 16, 96, 218, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnMin01 = GUICtrlCreateCheckbox("Minimize", 72, 64, 66, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnWdh01 = GUICtrlCreateCheckbox("Restore", 144, 64, 90, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnStart01 = GUICtrlCreateCheckbox("Start", 16, 32, 218, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlCreateGroup("", -99, -99, 1, 1) $grpInst3 = GUICtrlCreateGroup(" 3 ", 8, 136, 233, 121) $btnPause03 = GUICtrlCreateCheckbox("Pause", 16, 192, 50, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $tbnStop03 = GUICtrlCreateCheckbox("Stop", 16, 224, 218, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnMin03 = GUICtrlCreateCheckbox("Minimize", 72, 192, 66, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnWdh03 = GUICtrlCreateCheckbox("Restore", 144, 192, 90, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnStart03 = GUICtrlCreateCheckbox("Start", 16, 160, 218, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlCreateGroup("", -99, -99, 1, 1) $grpInst2 = GUICtrlCreateGroup(" 2 ", 248, 8, 233, 121) $btnPause02 = GUICtrlCreateCheckbox("Pause", 256, 64, 50, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $tbnStop02 = GUICtrlCreateCheckbox("Stop", 256, 96, 218, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnMin02 = GUICtrlCreateCheckbox("Minimize", 312, 64, 66, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnWdh02 = GUICtrlCreateCheckbox("Restore", 384, 64, 90, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnStart02 = GUICtrlCreateCheckbox("Start", 256, 32, 218, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlCreateGroup("", -99, -99, 1, 1) $grpInst4 = GUICtrlCreateGroup(" 4 ", 248, 136, 233, 121) $btnPause04 = GUICtrlCreateCheckbox("Pause", 256, 192, 50, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $tbnStop04 = GUICtrlCreateCheckbox("Stop", 256, 224, 218, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnMin04 = GUICtrlCreateCheckbox("Minimize", 312, 192, 66, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnWdh04 = GUICtrlCreateCheckbox("Restore", 384, 192, 90, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnStart04 = GUICtrlCreateCheckbox("Start", 256, 160, 218, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) GUICtrlSetBkColor(-1, 0x00FF00) $Edit1 = GUICtrlCreateEdit("", 8, 720, 473, 497) $btnPauseAll = GUICtrlCreateCheckbox("Pause all", 8, 656, 474, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnStopAll = GUICtrlCreateCheckbox("Stop all", 7, 688, 474, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 CheckGuiMsg() FileWrite($logfile, @HOUR & ":" & @MIN & ":" & @SEC & "> " & "CheckGuiMsg" & @CRLF) CheckClientMessages() FileWrite($logfile, @HOUR & ":" & @MIN & ":" & @SEC & "> " & "CheckClientMessages" & @CRLF) WEnd Func CheckGuiMsg() $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btnStart01 AddTextToEdit("Starting Instance 1") $PID[0] = Run("D:\XVM05\Entwicklung_FilterTest_Multi_ToFileV001.exe 1", @ScriptDir, Default, 3) Case $btnStart02 AddTextToEdit("Starting Instance 2") $PID[1] = Run("D:\XVM05\Entwicklung_FilterTest_Multi_ToFileV001.exe 2", @ScriptDir, Default, 3) Case $btnStart03 AddTextToEdit("Starting Instance 3") $PID[2] = Run("D:\XVM05\Entwicklung_FilterTest_Multi_ToFileV001.exe 3", @ScriptDir, Default, 3) Case $btnStart04 AddTextToEdit("Starting Instance 4") $PID[3] = Run("D:\XVM05\Entwicklung_FilterTest_Multi_ToFileV001.exe 4", @ScriptDir, Default, 3) Case $btnPause01 AddTextToEdit("Send Pause to Instance 1") StdinWrite($PID[0], "Pause") Case $btnPause02 StdinWrite($PID[1], "Pause") Case $btnPause03 StdinWrite($PID[2], "Pause") Case $btnPause04 StdinWrite($PID[3], "Pause") Case $tbnStop01 StdinWrite($PID[0], "Stop") Case $tbnStop02 StdinWrite($PID[1], "Stop") Case $tbnStop03 StdinWrite($PID[2], "Stop") Case $tbnStop04 StdinWrite($PID[3], "Stop") Case $btnPauseAll AddTextToEdit(@CRLF & "************Pause All not yet implemented**************" & @CRLF) Case $btnStopAll AddTextToEdit(@CRLF & "************Stop All not yet implemented***************" & @CRLF) EndSwitch EndFunc ;==>CheckGuiMsg Func CheckClientMessages() For $i = 0 To 3 FileWrite($logfile, @HOUR & ":" & @MIN & ":" & @SEC & "> " & $i & @CRLF) Local $a = TimerInit() $p = $PID[$i] $streamRead = StdoutRead($p) If $streamRead <> "" Then Switch $streamRead Case StringInStr($streamRead, "Focus Needed") > 0 If $FocusAvailable Then $FocusAvailable = False StdinWrite($p, "Focus Granted") Else EndIf Case StringInStr($streamRead, "Release Focus") > 0 StdinWrite($p, "Release Focus Received") $FocusAvailable = True Case Else EndSwitch EndIf FileWrite($logfile, @HOUR & ":" & @MIN & ":" & @SEC & "> " & $i & " " & round(TimerDiff($a),2) & @CRLF) Next EndFunc ;==>CheckClientMessages Func AddTextToEdit($text) If $previousEditMsg <> $text Then $previousEditMsg = $text GUICtrlSetData($Edit1, GUICtrlRead($Edit1) & @YEAR & "." & @MON & "." & @MDAY & " - " & @HOUR & ":" & @MIN & ":" & @SEC & "> " & $text & @CRLF) _GUICtrlEdit_Scroll($Edit1, $SB_SCROLLCARET) EndIf EndFunc ;==>AddTextToEdit My issue now is that the mechanism with with StdoutRead and StdinWrite is not efficient at all. The more instances I start the slower it gets. This is not just a bit slower (like a fraction of a second), but to the degree that the front end is not responding at all any longer (with 3 instances handling). So my questions are: 1. Is there a flaw in my implementation with StdoutRead and StdinWrite? (note that all works fine with 1 and also (slower) with 2 instances running) but actually breaks down with 3 instances running. 2. Can I optimize the currently used implementation so that I can control 30+ instances? 3. What other implementation do you see suitable for this approach? a. I have already tried it with communication through files but observed that this is not sufficiently reliable with multiple instances. b. Is Named Pipes a more performant approach (I am a bit scared of the effort to learn and implement this) c. Any other method? Many thanks in advance -dubi
  9. $user = "root" $password ="" $host ="5.0.0.1" $port ="22" $puty_exe = @ScriptDir & "\putty.exe"; putty salve local folder script $command = Run(@comspec & " /C "&$puty_exe&" -ssh -l "&$user&" "&$host&" p "&$port&" -pw "&$password,@ScriptDir, @SW_HIDE, 1) While 1 $data = StdoutRead($command) ConsoleWrite($data&@CRLF) If @error Then ExitLoop Wend Why StdoutRead cant read what putty.exe write in console ?
  10. Perhaps someone would benefit off this. I made heavy use of the Help file example. Only question I have here, is is there a better way to do the Regex for finding "error|ERROR|Error" in the source string? Thx Example7zPwd() Func Example7zPwd() ;-- Local $iPID = Run(@ComSpec & " /c DIR Example.au3", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $iPID = Run(@ComSpec & " /c 7za t -pmasale myzip.zip ", "c:\files\testing", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $sOutput = "" Local $myError = 0 ConsoleWrite("$myError:" & $myError & @CRLF) While 1 $sOutput = StdoutRead($iPID) If @error Then ; Exit the loop if the process closes or StdoutRead returns an error. ExitLoop EndIf MsgBox($MB_SYSTEMMODAL, "Stdout Read:", $sOutput, 5) If StringRegExp($sOutput, '\b(error|ERROR|[Ee]rror)\b', 0) Then $myError = $myError + 1 ;ConsoleWrite("$sOutput: " & $sOutput & @CRLF) ConsoleWrite("$myError: " & $myError & @CRLF) WEnd While 1 $sOutput = StderrRead($iPID) If @error Then ; Exit the loop if the process closes or StderrRead returns an error. ExitLoop EndIf MsgBox($MB_SYSTEMMODAL, "Stderr Read:", $sOutput, 15) WEnd ConsoleWrite("$myError: " & $myError & @CRLF) If $myError > 0 Then MsgBox(64, "An Error Occurred", "The upgrade may be incomplete. An error occurred") EndIf If StringRegExp($sOutput, '\b(error|ERROR|[Ee]rror)\b', 0) Then Is the Regex here optimized?
  11. Question regarding StdinWrite and Stdoutread… Here’s my setup… I’m opening a powershell session using the AutoIT Run function with the $STDIN_CHILD and $STDOUT_CHILD optional flags. I’m then sending a command using the STDINWRITE function to connect to a remote server which is a long distance away and it takes a “long” time to return results. I’m then trying to read the STDOUT stream. After this there are other STDINWRITE statements that I need to make so the STREAM hasn’t closed at this point. My question is this…How do I know for sure when all the data has been returned from the remote server after my first STDINWRITE? Things I’ve tried and don’t work… Use a loop which waits for @error to be non-zero. This doesn’t work because as long as the STREAM is open then @error never is set to non-zero. Use a loop which waits for @extended to be 0. This doesn’t work because the remote server sends data back in bursts and I don’t know how much time will pass in-between bursts. The only thing that is somewhat reliable is utilizing very long sleep statements – like 5 minutes – which really slows down my script and doesn’t ensure success either. What I really need is a way to tell that control has been returned to the command prompt. What I mean by this is if you open a command prompt and issue the command DIR C:\ /s which lists all the files and folders on your C: drive you know you can’t issue any more commands until you get a blinking cursor at the command prompt again. How do I programatically know when I get a blinking cursor again? Sample code that isn’t 100% foolproof… This code uses the logic looking for an @error to be non-zero... #include <constants.au3> Dim $StrOutput $StrPowerShellPID = Run('C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe  -command - ',@SystemDir, @SW_HIDE, $STDIN_CHILD + $STDERR_MERGED) StdinWrite($StrPowerShellPID, "Dir C:\" & @CRLF) ;this is just an example command ; I can't close the STDOUT stream at this point because I need to issue additional commands into the existing STDIN stream later in the script While 1 ;Wait for EOF as indicated by @error being non-zero     $StrOutput &= StdoutRead($StrPowerShellPID)     If @error <> 0 Then ExitLoop     sleep (500) WEnd Consolewrite($StrOutput)The above code doesn't work because @error will never be set to non-zero since the stream isn't closed. I can't close the stream because I need to issue additional commands into it. This code uses logic looking for an @extended value of 0 indicating no data was returned to the stream... #include <constants.au3> Dim $StrOutput $StrPowerShellPID = Run('C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command - ',@SystemDir, @SW_HIDE, $STDIN_CHILD + $STDERR_MERGED) StdinWrite($StrPowerShellPID, "Dir ""C:\program files\common files"" -recurse" & @CRLF) While 1 ;This loop detects when data starts to stream in and then exits the loop $StrOutput &= StdoutRead($StrPowerShellPID) If @extended > 0 Then ExitLoop sleep(1000) WEnd While 1 ;Now that data has begun to stream in I wait until I can't read any more data as indicated by 0 bytes read in the value of @extended $StrOutput &= StdoutRead($StrPowerShellPID) If @extended = 0 Then ExitLoop ;~ sleep (1000) ; this is the only way to get this specific sample to work but this won't work for me because I don't know the time in-between bursts of data coming into the STDIN stream WEnd ConsoleWrite($StrOutput) ;If you look at the output you'll see it's not complete because @extended was set to 0 during the second loopThe above code doesn't always work because if the remote server doesn't send any data for several seconds, then the StdoutRead thinks it's done reading when in reality it may not be.
  12. Hey guys, I want to use Putty/Plink to connect on a remote computer via SSH because I need to execute a couple commands there. So I researched a couple days now and tried like 20 different ways to get this running but I'm still failing. Maybe a little description what my script should do: #Edit: Short version: I need to use StdoutRead to get the DOS command promt output MORE THAN ONCE! The first time is working, but I need to get this the whole time till I say stop ^^ I want to start Putty/Plink and connect via SSH on a remote computer AND I wanna check if there is anything wrong going on or not, because the next step would be the execution of an perl-script on the remote computer which is giving an output text while running. That means I'd like to be able to read out the Putty-Window/Plink-Console the whole time ... I'm actual just getting the text-output after connecting. Maybe a little example of what I'm expecting in some kind of mixed "AutoIt/Pseudo -Code": #include <Constants.au3> Local $iPID = Run('"C:\Program Files (x86)\Putty\putty.exe" -ssh root@HOST:22 -pw PASSWORD', @ScriptDir, @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD) Actual Putty-Window is popping up showing me: Using username "root". Linux COMPUTERNAME 2.6.31-22-generic-pae #63-Ubuntu SMP Wed Aug 18 23:57:18 UTC 2010 i686 To access official Ubuntu documentation, please visit: http://help.ubuntu.com/ System information as of Mo 13. Jan 15:01:50 CET 2014 System load: 0.0 Processes: 77 Usage of /: 47.5% of 9.15GB Users logged in: 1 Memory usage: 9% IP address for eth2: HOST Swap usage: 0% Graph this data and manage this system at https://landscape.canonical.com/ Last login: Mon Jan 13 14:58:43 2014 from XXX.X.X.XXX root@COMPUTERNAME:~# Now I'd like to do ControlSend($hWindow_Putty, '', '', 'perl -w /some/dir/script.pl{ENTER}') If I'd do this on my on with Putty I'd now see something like: Using username "root". Linux COMPUTERNAME 2.6.31-22-generic-pae #63-Ubuntu SMP Wed Aug 18 23:57:18 UTC 2010 i686 To access official Ubuntu documentation, please visit: http://help.ubuntu.com/ System information as of Mo 13. Jan 15:01:50 CET 2014 System load: 0.0 Processes: 77 Usage of /: 47.5% of 9.15GB Users logged in: 1 Memory usage: 9% IP address for eth2: HOST Swap usage: 0% Graph this data and manage this system at https://landscape.canonical.com/ Last login: Mon Jan 13 14:58:43 2014 from XXX.X.X.XXX root@COMPUTERNAME:~# perl -w some/dir/script.pl some text written by the script.pl some text written by the script.pl some text written by the script.pl root@COMPUTERNAME:~# And that's what my problem is. I need to be able to check this output of the script like "some text written by the script.pl" because I may not execute a following statement if this one didn't succeed. In my thoughts the first step should show me what I got in the first code-box above, and the second output should be perl -w some/dir/script.pl some text written by the script.pl some text written by the script.pl some text written by the script.pl root@COMPUTERNAME:~# but I dont get this working ... So I found many threads about Plink. I tried the whole thing with Plink... Local $sData = '' Local $iPID = Run('"C:\Program Files (x86)\Putty\plink.exe" -ssh root@HOST:22 -pw PASSWORD', @ScriptDir, @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD) While True $sData &= StdoutRead($iPID) If @error Then ExitLoop Sleep(25) WEnd ConsoleWrite("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & @CR & _ $sData & @CR & _ "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & @CR) I'm getting the following output: Linux COMPUTERNAME 2.6.31-22-generic-pae #63-Ubuntu SMP Wed Aug 18 23:57:18 UTC 2010 i686 To access official Ubuntu documentation, please visit: http://help.ubuntu.com/ System information as of Mo 13. Jan 15:35:53 CET 2014 System load: 0.0 Processes: 77 Usage of /: 47.5% of 9.15GB Users logged in: 1 Memory usage: 9% IP address for eth2: HOST Swap usage: 0% Graph this data and manage this system at https://landscape.canonical.com/ Last login: Mon Jan 13 15:23:36 2014 from MY_IP_ADRESS In comparison to the Putty window-output I'm missing here the root@COMPUTERNAME:~# line ... anyway, I don't get this Plink thing doing more then just connecting ... no more executions I'm getting done ... I also tried something like: #RequireAdmin #include <Constants.au3> Local $sData = '' Local $iPID = ShellExecute(@ComSpec, '"C:\Program Files (x86)\Putty\plink.exe" -ssh root@HOST:22 -pw PASSWORD', @ScriptDir, '', @SW_SHOW) Local $hWindow = WinWait('Administrator: C:\Windows\system32\cmd.exe', '', 5) ConsoleWrite("WinWait: " & $hWindow & @CR) If $hWindow = 0 Then Exit ConsoleWrite("WinActivate: " & WinActivate('Administrator: C:\Windows\system32\cmd.exe') & @CR) ConsoleWrite("WinActive: " & WinActive('Administrator: C:\Windows\system32\cmd.exe') & @CR) Sleep(1000) ConsoleWrite(ControlSend('Administrator: C:\Windows\system32\cmd.exe', '', '', '"C:\Program Files (x86)\Putty\plink.exe" -ssh root@HOST:22 -pw PASSWORD{ENTER}') & @CR) ;StdinWrite($iPID, '"C:\Program Files (x86)\Putty\plink.exe" -ssh root@HOST:22 -pw PASSWORD' & @CRLF) ;StdinWrite($iPID) While True $sData &= StdoutRead($iPID) If @error Then ExitLoop Sleep(25) WEnd ConsoleWrite("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & @CR & _ $sData & @CR & _ "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & @CR) but unfortunately I dont get anything out of it ... Maybe a last more example ... I found this on Stackoverflow (http://stackoverflow.com/questions/19206834/command-prompt-and-autoit-stdinwrite) Thats my code after reading that article: #include <Constants.au3> Local $data Local $pid = Run("C:\Windows\system32\cmd.exe",@SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD) StdinWrite($pid,"cd C:\users\username") StdinWrite($pid,@CRLF) ;~ StdinWrite($pid) Sleep(2000) $data &= StdoutRead($pid) ConsoleWrite("Debug:" & $data & @LF) $data = '' StdinWrite($pid,"cd C:\Program Files (x86)") StdinWrite($pid,@CRLF) StdinWrite($pid) $data &= StdoutRead($pid) ConsoleWrite("Debug:" & $data & @LF) but the second output still empty... Can you guys please help me out? Thanks in advice. Regards.
  13.  Whenever I try to run this simple command it does not work with the constants at the end. If I remove the $STDERR_CHILD and $STDOUT_CHILD, the command works but of course I can't capture the text. I've tried many ways. I have the autoconstants include declared also. I looked at other topics in the forum and many are very old but didn't seem to be this scenario. AutoIt ver 3.3.12 Local $get = Run(@ComSpec & " /c ipconfig","",@SW_SHOW,$STDERR_CHILD + $STDOUT_CHILD) While 1 $sOutput = StdoutRead($get) If @error Then ExitLoop EndIf MsgBox($MB_SYSTEMMODAL, "Stdout Read:", $sOutput) WEnd
  14. Someone told me I should post this in the examples section. I wrote this to make it easy for me to call a Windows console application and get its output using a single line of AutoIt code. I hope it's helpful to someone else. #include <Constants.au3> ; Examples: MsgBox(0,"Windows Version",_RunWaitGet(@ComSpec & " /c ver",1,"",@SW_HIDE)) MsgBox(0,"System Info",_RunWaitGet(@SystemDir & "\systeminfo.exe",1)) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _RunWaitGet ; Description ...: Runs the specified process, waits for it to exit, then returns the contents of its StdOut and/or StdErr streams. ; Handy for running command-line tools and getting their output. ; Syntax ........: _RunWaitGet($sProgram, $nOptions, $sWorkingDir, $nShowFlag) ; Parameters ....: $sProgram - The full path of the program (EXE, BAT, COM, or PIF) to run ; $nOptions - Add options together: ; 1 = Capture the StdOut stream. ; 2 = Capture the StdErr stream. ; 4 = Return when the stream(s) close(s), not when the process ends. ; $sWorkingDir - The working directory. Blank ("") uses the current working directory. ; This is not the path to the program. ; $nShowFlag - The "show" flag of the executed program: ; @SW_SHOW = Show window (default) ; @SW_HIDE = Hidden window (or Default keyword) ; @SW_MINIMIZE = Minimized window ; @SW_MAXIMIZE = Maximized window ; Return values .: String value containing the captured contents. ; If there was a problem running the process, @error is set to the @error value returned by Run(). ; Otherwise, @error is 0. ; Author ........: ToasterKing ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: MsgBox(0,"System Info",_RunWaitGet(@SystemDir & "\systeminfo.exe",1)) ; MsgBox(0,"Windows Version",_RunWaitGet(@ComSpec & " /c ver",1,"",@SW_HIDE)) ; =============================================================================================================================== Func _RunWaitGet($sProgram,$nOptions = 0,$sWorkingDir = @SystemDir,$nShowFlag = @SW_SHOW) Local $nRunOptFlags = 0,$sStreamOut = "" ; Initialize variables ; Determine flags for parent/child interaction If BitAND($nOptions,1) Then $nRunOptFlags += $STDOUT_CHILD If BitAND($nOptions,2) Then $nRunOptFlags += $STDERR_CHILD Local $hRunStream = Run($sProgram,$sWorkingDir,$nShowFlag,$nRunOptFlags) ; Run the process If @error Then Return SetError(@error,@extended,0) ; If there was an error code, return it. Otherwise... While 1 ; Loop until the end of the stream, which indicates that the process has closed it (which usually means the process ended) If BitAND($nOptions,1) Then ; If user specified to capture STDOUT stream... $sStreamOut &= StdoutRead($hRunStream) ; Append new stream contents to existing variable while removing those contents from the stream. If @error = 2 And BitAND($nOptions,4) Then ExitLoop ; If stream ended and user specified to return when the stream closes, stop looping. EndIf If BitAND($nOptions,2) Then ; If user specified to capture STDERR stream... $sStreamOut &= StderrRead($hRunStream) ; Append new stream contents to existing variable while removing those contents from the stream. If @error = 2 And BitAND($nOptions,4) Then ExitLoop ; If stream ended and user specified to return when the stream closes, stop looping. EndIf If Not BitAND($nOptions,4) And Not ProcessExists($hRunStream) Then ExitLoop ; If using the default setting and the process ended, stop looping. Sleep(100) ; To avoid overloading the CPU WEnd Return SetError(0,0,$sStreamOut) ; Return the captured contents and @error = 0 EndFunc
  15. Dear Autoit Forum, Before I start, I have checked the following topics, but couldn't get far enough: '?do=embed' frameborder='0' data-embedContent>> Func _PLINK_Connect($remote, $user, $password) Local $hSessionPID = Run("plink.exe -ssh " & $remote & " -l " & $user & " -pw " & $password, "", @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD) If @error Then MsgBox(0, "Error: xxx", "Running plink.exe under the main folder failed.") Return False EndIf Local $sLine While True ;read each line $sLine = StdoutRead($hSessionPID) ;ty_DEBUG print each line after connected If $sLine <> "" Then ConsoleWrite("Current Line Start:" & $sLine & @CRLF & "==== Current Line End" & @CRLF) If ProcessExists($hSessionPID) = 0 Then ConsoleWrite("cannot find PID" & @CRLF) Return SetError(9) ;check if connected with the given user name ElseIf StringInStr($sLine, "Using keyboard") Then ConsoleWrite("cannot login" & @CRLF) Return SetError(8) ;check if connected to remote ElseIf StringInStr($sLine, " [cdr2db] :") Then ConsoleWrite("connected to remote" & @CRLF) ExitLoop EndIf Sleep(10) WEnd Return $hSessionPID EndFunc Now i call the function: Case1: Everything is fine _PLINK_Connect("10.25.0.20", "cdr2db", "Cdr2db_1") Output: Current Line Start:Last login: Sat Sep 13 12:56:06 2014 from 10.75.58.71 ==== Current Line End Current Line Start:<101 bb1a [cdr2db] :/onip/app/cdr2db> ==== Current Line End connected to remote Case2: Another username _PLINK_Connect("10.25.0.20", "cdr2dba", "Cdr2db_1") Output: Current Line Start:Using keyboard-interactive authentication. Password: ==== Current Line End cannot login Using username "cdr2dba". Access denied Case3: Wrong password _PLINK_Connect("10.25.0.20", "cdr2db", "Cdr2db_1a") Output: Current Line Start:Using keyboard-interactive authentication. Password: ==== Current Line End cannot login Using username "cdr2db". Access denied Case4: Non-existing remote machine Output: FATAL ERROR: Network error: Connection timed out cannot find PID Now my question is that: For Case 2 and 3; my last console write says that "current line start / end" then, "cannot login". But in the output window i can find "Using username cdr2db. Access denied". So, how is that output generated? For Case 4: Even there is no output as ConsoleWrite, how the "FATAL ERROR: ..." line is generated? I would apperiate any comments on the topic. Thanks in advance.
  16. Is there any way to retrieve the exit code from a process while also being able to use StdoutRead/StderrRead?
  17. I have a script that executes powershell commands to interact with Office 365(Microsoft hosted Exchange service). I want to hide the powershell window and interpret the output silently, so that non-savvy users can reset passwords and such without having to learn powershell or understand its errors. However, when I use: Func RunCommand($commandtorun) $output = "" If WinExists("Administrator:") Then WinActivate("Administrator:") Send($commandtorun & "{ENTER}") While 1 $output &= StdoutRead($pwshell) If @error Then ExitLoop WEnd MsgBox(0, "stdoutread", $output) EndFunc ;==>RunCommand It doesn't exit the loop until I close the powershell window.(by design I believe) Is there another way to return just a particular command's output? Also, if I use $Stdin_child, the powershell window doesn't display its prompt for a command until I close my script. Is that by design also?
  18. I found this topic: but it doesn't seem to solve my problem. I'm trying to create a script to help my guys provision new Cisco switches for deployment. I was hoping to find a nice, easy way to send data over a serial connection (similar to TCPSend), but alas. I read a lot about mscomm32.ocx and netcomm.ocx, but there seem to be licensing issues. Plink seems to be a good bet, but my attempts at reading the output are not working. If I run plink manually, (to an unconfigured switch) I get a Switch>_ prompt. But when I run the same command here, my stdoutread loop never ends. Any way around this? #include $plink = Run(@ComSpec & " /c plink.exe -v -load serial","",@SW_HIDE,$STDIN_CHILD + $STDERR_MERGED) StdinWrite($plink,@CR) StdinWrite($plink) Local $data While True $data &= StdoutRead($plink) If @error Then ExitLoop WEnd MsgBox(0,"",$data)
  19. What I am attempting to do is use AutoIt to read and write to the minecraft (bukkit) console The console itself comes up as a cmd window when you start the jar with a .bat file. So far I have been able to read FROM StdoutRead, but I have had less success writing TO the console and getting any kind of response. Here is the server, example .bat file, and the following script: #include <GuiEdit.au3> OnAutoItExitRegister("close") hotkeyset("{ENTER}","enter") $GUI = GUICreate("MC Console Wrapper", 514, 251, 192, 124) $Edit = GUICtrlCreateEdit("", 8, 8, 497, 209, 2101312) $Input = GUICtrlCreateInput("", 8, 224, 497, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $temp = FileFindFirstFile("*.bat") $server = run(FileFindNextFile($TEMP),@WorkingDir,default,0x7) ConsoleWrite($server&@CRLF) While 1 $temp = "" $temp = StderrRead($server) if @extended > 2 then GUICtrlSetData($Edit,guictrlread($Edit)&@CRLF&$temp) _GUICtrlEdit_Scroll($Edit, 7) EndIf $temp = StdoutRead($server) if @extended > 2 then GUICtrlSetData($Edit,guictrlread($Edit)&@CRLF&$temp) _GUICtrlEdit_Scroll($Edit, 7) EndIf $nMsg = GUIGetMsg() Switch $nMsg Case -3 Exit EndSwitch WEnd func enter() if WinActive($gui) Then If guictrlread($Input) <> "" Then StdinWrite($server,guictrlread($Input)) consolewrite(@error&@CRLF) GUICtrlSetData($Input,"") EndIf Else hotkeyset("{ENTER}") send("{enter}") hotkeyset("{ENTER}","enter") EndIf EndFunc func close() Do ProcessClose("java.exe") until ProcessExists("java.exe") = 0 EndFuncAny help would be appreciated
  20. I'm using to upload a file to a server. After the upload the server returns a URL to that file. My program needs to give that URL to the user. libcURL is working fine and the upload is successful, and the HTML response needed is output to scite's console. I need the information put into the console to be stored in a variable, though, and I can't figure it out. I think I need to use stdout or stdread to do this. I have used these before when using a run() command but this library is using a dll (and is much cleaner than my previous version which used run commands). How do I record the output buffer of a DLL? (or whatever stdout is called). This attachment is what I'm testing it with, just open "playground.au3" and run it. It should spit a bunch of information to the console. The top listing of variables is all from curl_getdata(), the part with brackets and arrows is from my web server. I need the second part to be put into a variable. PS: The cURL process ID is stored as $__hcurl_process seangriffin's manages to accomplish this, it looks like the key is to use "DllCallbackRegister". I'm trying to plug this in to smartee's UDF but the two UDF's look like completely different languages. I don't think I will be able to figure this out on my own, but I'm going to keep trying. EDIT: You need to move the DLL's to the same folder as playground.au3, and edit "libcURL.au3" and change the #include to quotes instead of brackets. I packed it wrong.
×
×
  • Create New...