Jump to content

Using pipes in AutoIt. Like "|" in CMD files.


Exit
 Share

Recommended Posts

Here is a simple solution for CMD piping.

; Example of piping in AutoIt

; define commands to pipe
$sCmd1 = "dir " & @SystemDir & "\*.*" ; display all files of system directory
$sCmd2 = "find /I "".exe""" ; select all EXE files
$sCmd3 = "find /I ""di""" ; select all files with 'di' as substring

; run commands concurrent
$iPID1 = Run(@ComSpec & " /C " & $sCmd1, "", @SW_HIDE, 9) ; $STDIN_CHILD(1) + $STDERR_MERGED(8)
$iPID2 = Run(@ComSpec & " /C " & $sCmd2, "", @SW_HIDE, 9) ; $STDIN_CHILD(1) + $STDERR_MERGED(8)
$iPID3 = Run(@ComSpec & " /C " & $sCmd3, "", @SW_HIDE, 9) ; $STDIN_CHILD(1) + $STDERR_MERGED(8)

; pipe output of first command as input to second command
While Sleep(10)
    $sTmp = StdoutRead($iPID1, False, True)
    If @error Then ExitLoop StdinWrite($iPID2)
    StdinWrite($iPID2, $sTmp)
WEnd

; pipe output of second command as input to third command
While Sleep(10)
    $sTmp = StdoutRead($iPID2, False, True)
    If @error Then ExitLoop StdinWrite($iPID3)
    StdinWrite($iPID3, $sTmp)
WEnd

; display output of third command
MsgBox(Default, Default, StdoutRead($iPID3), 0)

App: Au3toCmd              UDF: _SingleScript()                             

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...