Sign in to follow this
Followers
0

SOLVED: Problem executing compiled AU3 scripts from Cygwin Bash script
By
tremolux66, in Misc
-
Recently Browsing 0 members
No registered users viewing this page.
-
Similar Content
-
By CiaronJohn
Hi,
I would like to read the output of my cygwin terminal if it is already up and running.
I searched the forum, but I think, the samples were cmd/cygwin needs to be re-run or not yet running.
The purpose of the script is to check if compiling is done.
Func _JAE_Rebuild_Software ($sSoftwarePath)
Local $iMinty = 0
; Open cygwin process and check one instance only
if ProcessExists("mintty.exe") Then
$iMinty = ProcessExists("mintty.exe")
Else
; Run cygwin if not yet running
$iMinty = Run("C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico -", "", @SW_SHOW, $STDIN_CHILD + $STDOUT_CHILD)
endif
; Loop to check if cygwin terminal is ready
While 1
; if -sh is not error cygwin is still opening
Local $hWnd = WinGetHandle("-sh")
If @error Then
$hWnd = WinGetHandle("~")
Else
$hWnd = 0
EndIf
; If true cygwin is ready to be written
if $hWnd <> '0x00000000' Then
ExitLoop
EndIf
WEnd
; Change Directory
$sSoftwarePath = StringReplace($sSoftwarePath,"\", "/")
ClipPut($sSoftwarePath)
Send('cd ' & $sSoftwarePath & "{ENTER}" )
; Get New Class after Change Directory
Local $sNewClass = WinGetTitle("[ACTIVE]")
; Sleep for 3 seconds.
Sleep(3000)
; Change software path to access the makeFile
$sSoftwarePath = StringReplace($sSoftwarePath,"/", "\")
; Open Makefile
Local $hFileOpen = FileOpen($sSoftwarePath & "\makefile", $FO_READ)
If $hFileOpen = -1 Then
Return False
EndIf
Local $sFileRead = FileReadLine($hFileOpen, 12)
Local $sSetSource = _StringBetween($sFileRead, "(", ")", $STR_ENDNOTSTART)
Local $message
Send('source ' & $sSetSource[0] & '.sh' & "{ENTER}")
Send('make clean' & "{ENTER}")
WinActivate($sNewClass, "")
$hWnd = WinWait($sNewClass,"",1)
Local $iPID = WinGetProcess($hWnd)
While $iMinty
$message &= StderrRead($iPID)
If @error Then
MsgBox(0,"","error")
ExitLoop
EndIf
WEnd
; I only get blank output here since the while condition produces an error
MsgBox(0, "Stdout Read:", $message)
EndFunc ;==>_JAE_Rebuild_Software
-
By iamtheky
This thread will focus on the scripts that write/execute bash scripts, and return the data (whereas my other thread is more just a spit sink). Currently you are relegated to piping to a file from the bash script, hopefully there are other options coming.
This AutoIt script writes a bash script containing an fdupes command based off the Directory you want to search, and whether or not you want it to recurse. It writes the script in Temp, runs it, writes the stdout to a file in Temp, then parses that file and returns you an array.
* You need to sudo apt-get install fdupes for this to work, btw. fdupes is stupid fast at what it does and being able to leverage linux features, not hunt down a windows equivalent, is great fun.
#requireadmin #include <WinAPIFiles.au3> #include <Array.au3> _WinAPI_Wow64EnableWow64FsRedirection(FALSE) _ArrayDisplay(_fdupes("c:\Users\" & @UserName & "\Desktop" , 1)) Func _fdupes($DirToCheckForDupes , $Recurse = 0) $bashscript = "c:\Windows\Temp\PRODfdupes.txt" $bashoutput = "c:\Windows\Temp\PRODfdupes_STDOUT.txt" ;format Windows Dir name to linux Dir name - DUPESDIR $aDupesDir = stringsplit($DirToCheckForDupes , "\" , 2) $sDupesDir = "//mnt/" & stringleft($DirToCheckForDupes , 1) for $i = 1 to ubound($aDupesDir) - 1 $sDupesDir &= "/" & $aDupesDir[$i] Next ;format Windows Dir name to linux Dir name - ScriptDIR $aScriptDir = stringsplit($bashscript , "\" , 2) $sScriptDir = "//mnt/" & stringleft($bashscript , 1) for $i = 1 to ubound($aScriptDir) - 1 $sScriptDir &= "/" & $aScriptDir[$i] Next ;format Windows Dir name to linux Dir name - OUTDIR $aOutDir = stringsplit($bashoutput , "\" , 2) $sOutDir = "//mnt/" & stringleft($bashoutput , 1) for $i = 1 to ubound($aOutDir) - 1 $sOutDir &= "/" & $aOutDir[$i] Next FileDelete($bashscript) FileDelete($bashoutput) $ErrFileWrite = $Recurse = 0 ? FileWrite($bashscript , "fdupes " & $sDupesDir & " > " & $sOutDir) : FileWrite($bashscript , "fdupes -R " & $sDupesDir & " > " & $sOutDir) $iPID = runwait('cmd /c bash ' & $sScriptDir) $Finalarr = stringsplit(fileread($bashoutput) , chr("10") , 2) return $Finalarr EndFunc ;fdupes
-
By iamtheky
This thread will house the scripts i (or anyone who contributes) create while playing with Bash on Windows.
First up, a simple mount command. I am still trying to get the stdout, but piping to files will suffice for now. I am running Win 10 Build 14342.rs1_release.160506-1708
**Do -- Until will be cleaned up (or completely scrapped) when i can find a reliable way to deal with output.
#include<array.au3> #include <WinAPIFiles.au3> _WinAPI_Wow64EnableWow64FsRedirection(False) $outfile = "test_mount_output.txt" $iPID = run("C:\Windows\System32\bash.exe | mount > " & $outfile , "" , @SW_HIDE) Do sleep(100) Until FileExists($outfile) sleep(100) processclose($iPID) _ArrayDisplay(stringsplit(stringtrimright(fileread($outfile) , 1) , @LF , 2))
-
By jguinch
Hi all !
I work on a tool for automating logon in a business software. This software is a Linux application, displayed in Windows with an EXPORT DISPLAY method, using a X-SERVER (Cygwin/Xterm).
The problem is when I use Send or ControlSend, special keys like @ or # (or some other keys needing an AltGr combination), the characters sent are the non-AltGr keys (# become 3, @ become 3 - I use a French keyboard).
I tried to send keys to the Linux-Firefox (instead of the business software), but I had the same result.
Does anyone has already try to make something like this, with the same issue ?
Thanks for help
-