Jump to content

stdoutread issue


Recommended Posts

Ok, I don't know if this type of issue can be handled by sending standard output to a variable, I am using curl, a command line ftp program to send a zipped file over a secure connection and have the output (which is a data time/sent meter) display in the GUI instead of having to display the command prompt. I've looked through the help files and many posts on the forum but I either see something that doesn't apply or i'm just not grasping the idea. When I attempt to send the standard output to the window I get nothing. Here's a portion of the code, I'm not sure if the standard output will do this since the information is a constant stream, I've even waited until the file was sent but still receive no output of any kind.

Do
_getDOSOutput('c:\wakeforestftp\curl\curl.exe --ftp-ssl -v -k -T c:\testdata\' & $NameAndDate & '*.zip ftp://ftpserverinfo')
Until Not ProcessExists("curl.exe")
Sleep(2000)

Func _getDOSOutput($command)
    Local $text = '', $Pid = Run(@ComSpec & ' /c ' & $command, '', @SW_HIDE, 2 + 4)
    While 1
        $text &= StdoutRead($Pid)
        If @error Then ExitLoop
    
        $Arr = StringSplit($text,@LF)
    _ArrayDisplay($Arr)
    For $x = 1 To UBound($Arr) - 1
        $Arr[$x] = StringTrimRight($Arr[$x],1)
        _GUICtrlListBox_InsertString($Dataret,$Arr[$x],-1)
    Next
    WEnd
;Return GUICtrlSetData($Output,$text)
EndFunc  ;==>_getDOSOutput
Link to comment
Share on other sites

Some console programs use also stderr to output text. So you may need to use StderrRead too. However, it is better to merge stdout and stderr by using the flag 8 to be able to read data only with StdoutRead.

$Pid = Run(@ComSpec & ' /c ' & $command, '', @SW_HIDE, 8)
Edited by aec
Link to comment
Share on other sites

Some console programs use also stderr to output text. So you may need to use StderrRead too. However, it is better to merge stdout and stderr by using the flag 8 to be able to read data only with StdoutRead.

$Pid = Run(@ComSpec & ' /c ' & $command, '', @SW_HIDE, 8)
I tried what you suggested and I'm still not getting any output display, could it be that it's because the data is a constant feed and it can't check a continuous feed at specified intervals?
Link to comment
Share on other sites

Hi,

please try this snippet ...

; switch -v for verbose is maybe useful.
$pid_cURL = Run(@ScriptDir & '\curl.exe -v "' & $sUrl & '"', '', @SW_SHOW, 6)

; you have to try or study the manual on which
; stream the output is verbosed, but I assume
; that it is the error stream.
While True
    
;   $line = StdoutRead($pid_cURL)
    $line = StderrRead($pid_cURL)
    If @error Then ExitLoop
    
    ConsoleWrite($line)
    
WEnd

Greetz

Greenhorn

Edited by Greenhorn
Link to comment
Share on other sites

Hi,

please try this snippet ...

; switch -v for verbose is maybe useful.
$pid_cURL = Run(@ScriptDir & '\curl.exe -v "' & $sUrl & '"', '', @SW_SHOW, 6)

; you have to try or study the manual on which
; stream the output is verbosed, but I assume
; that it is the error stream.
While True
    
;   $line = StdoutRead($pid_cURL)
    $line = StderrRead($pid_cURL)
    If @error Then ExitLoop
    
    ConsoleWrite($line)
    
WEnd

Greetz

Greenhorn

Thank you So much Greenhorn and Aec both for your help. I tried the code you sent me Greenhorn and it fixed my issue! I had attempted to use StderrRead before in another program and just received a number code so I wasn't sure what that was, I didn't think data output would fall under that category.
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...