LyonR Posted February 3, 2023 Posted February 3, 2023 Can any explaine why this happens ? ;WHen I use single quates ' the = sign disapears Local $a = " 'Test=Test' " Local $b = ' "Test=Test" ' MsgBox( 0, "Test", $a ) ; OK MsgBox( 0, "Test", $b) ; OK Run("TestCQl.cmd" & $a ) ;Missing = Run("TestCQl.cmd" & $b ) ; OK ;Just at simpel file there writes output to a Dos Console ;TestCQL.cmd ;@echo off ;echo %1 %2 %3 %4 %5 %6 %7 %8 BG Lyon
rudi Posted February 3, 2023 Posted February 3, 2023 (edited) Interesting catch. This seems not to be autoit related, but the way @comspec (cmd.exe) is handling parameters: Local $a = "'Test=Test'" Local $b = '"Test=Test"' ; MsgBox( 0, "Test", $a ) ; OK ; MsgBox( 0, "Test", $b) ; OK $result=RunWait(@ComSpec & " /c c:\temp\Test.cmd " & $a , @TempDir) ;Missing = $result=RunWait(@ComSpec & " /c c:\temp\Test.cmd " & $b , @TempDir) ; OK rem C:\temp\test.cmd @echo on echo paramstr0=%0 echo paramstr1=%1 echo paramstr2=%2 echo paramstr3=%3 REM ... use shift to access params > 9 pause Edited February 3, 2023 by rudi Earth is flat, pigs can fly, and Nuclear Power is SAFE!
LyonR Posted February 3, 2023 Author Posted February 3, 2023 Hi Rudi Your right, if I parse 'Test=Test' on a command line the = disappears
philpw99 Posted February 3, 2023 Posted February 3, 2023 In windows cmd, the standard separator is double quote. Somehow "=" is also a valid but unofficial separator. So in the above example, $a is actually: 'Test=Test' , $b is actually "Test=Test" cmd interpret the 'Test=Test' as two parameters: ['Test] and [Test'], so the "=" just disappeared as an separator.
Solution LyonR Posted February 3, 2023 Author Solution Posted February 3, 2023 It's for passing password to a CLI program. The "funny" thing are that echo Test^=Test are working but echo 'Test^=Test' are not. So if my user are using " in the password I use 'Password' and if they use = I use "Password", and then I hobe that they are not using "= Thank guy's for pointing me in the right direction.
rudi Posted February 6, 2023 Posted February 6, 2023 to get output from and pass input to an CLI program you can interactively get / put both using run (not runwait) and the $PID to interact with the CLI #include <AutoItConstants.au3> $MyPWD="echo Top*secreT99" AdlibRegister("ToolTipUpdater") $StrOut="" $PID=run(@ComSpec,@TempDir,@SW_HIDE,$STDIN_CHILD + $STDERR_MERGED) $start=TimerInit() ; to exit the currently infinte while loop after 30 seconds while ProcessExists($PID) $StrOut&=StdoutRead($PID) ; do what you need to analyse output, e.g. if StringRight($StrOut,1)=">" Then StdinWrite($PID,$MyPWD & @CRLF) Sleep(1000) EndIf if TimerDiff($start) > (30*1000) Then ProcessClose($PID) ExitLoop EndIf WEnd StdioClose($PID) MsgBox(0,"PID vanished","PID " & $PID & " doesn't exist any more.") Func ToolTipUpdater() ToolTip($StrOut) EndFunc Earth is flat, pigs can fly, and Nuclear Power is SAFE!
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