nicknuke Posted February 20, 2022 Posted February 20, 2022 I am creating a simple one liner command to ssh server so "normal" user can do one simple task from their windows machine without command line, just a plain gui and a click of a button. I've managed to get it work so far ( taking scripts from this awesome forum, tbh.. ) The problem is when i test it, it can dump the output just fine on output panel in autoit ( consolewrite ), but when i redirect it to an editbox, the format is awfull... Would anyone care to help me with how to format the output on editbox to be the same like consolewrite output ? the script snippet is here : $answer = _runSshCommand($unixUser, $unixHost, $sshCommand, $unixPassword) ConsoleWrite($answer) GUICtrlSetData($Edit1,$answer & @CRLF) And the output is here, both consolewrite and editbox.. Thank you in advance ..
Nine Posted February 20, 2022 Posted February 20, 2022 Just set the edit box to a fixed size font ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
nicknuke Posted February 20, 2022 Author Posted February 20, 2022 (edited) 20 minutes ago, Nine said: Just set the edit box to a fixed size font ? No go I tried your suggestion right away, and set editbox font to fixedsys monospace font.. the output is still messed up .. Koda's simple gui : $Form1 = GUICreate("Form1", 826, 695, 571, 248) $Edit1 = GUICtrlCreateEdit("", 368, 56, 393, 553, BitOR($ES_AUTOHSCROLL,$WS_HSCROLL,$WS_VSCROLL,$WS_BORDER), $WS_EX_STATICEDGE) ;GUICtrlSetData(-1, "Edit1") GUICtrlSetFont(-1, 8, 400, 0, "Fixedsys") $showleasebtn = GUICtrlCreateButton("Show Lease", 104, 96, 99, 33) GUISetState(@SW_SHOW) Edited February 20, 2022 by nicknuke
Nine Posted February 20, 2022 Posted February 20, 2022 Copy the output to a notepad file and attach that file here. Make a small snippet of your edit box so we can test it here, reading the file. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Zedna Posted February 21, 2022 Posted February 21, 2022 I think that problem is LF as end of line in your output but for EditBox you need CRLF. Resources UDF ResourcesEx UDF AutoIt Forum Search
nicknuke Posted February 22, 2022 Author Posted February 22, 2022 (edited) On 2/21/2022 at 12:53 AM, Nine said: Copy the output to a notepad file and attach that file here. Make a small snippet of your edit box so we can test it here, reading the file. I changed the command to a simple "ls -l <directory> on linux machine, the result is pretty much the same.. It even has "quite right" display when it's being output to msgbox.. here are all the snip and snaps.. I dumped the output to editbox,msgbox, and consolewrite.. #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 835, 634, 622, 236) $Edit1 = GUICtrlCreateEdit("", 240, 24, 577, 561,BitOR( $ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY)) GUICtrlSetData(-1, "Edit1") $showleasebtn = GUICtrlCreateButton("ls -l", 56, 72, 107, 33) $restartbtn = GUICtrlCreateButton("Restart DHCP", 54, 146, 107, 33) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Here is the main call : While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $showleasebtn $sshCommand = "ls -l /home/wolf/" $answer = _runSshCommand($unixUser, $unixHost, $sshCommand, $unixPassword) ConsoleWrite($answer) GUICtrlSetData($Edit1,$answer & @CRLF) MsgBox(0,"SSH Output", $answer) ;Case $Edit1 EndSwitch WEnd Thanks in advance... 21 hours ago, Zedna said: I think that problem is LF as end of line in your output but for EditBox you need CRLF. Could it be ? Because editbox expected DOS command output CRLF, while the linux/unix ssh terminal output only produce LF ? If that's true.. that's a bummer for me then 😐 output-autoit.txt Edited February 22, 2022 by nicknuke
Nine Posted February 22, 2022 Posted February 22, 2022 (edited) Well the data you gave me is probably not the one you get from. Because it working fine with me... #include <Constants.au3> #include <GUIConstants.au3> #include <FontConstants.au3> $Form1 = GUICreate("Form1", 835, 634, 622, 236) $Edit1 = GUICtrlCreateEdit("", 240, 24, 577, 561,BitOR( $ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY)) GUICtrlSetFont(-1, 10, $FW_NORMAL, $GUI_FONTNORMAL, "Lucida Console") $showleasebtn = GUICtrlCreateButton("Read txt", 56, 72, 107, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $showleasebtn $answer = FileRead("output-autoit.txt") GUICtrlSetData($Edit1,$answer & @CRLF) MsgBox(0,"SSH Output", $answer) EndSwitch WEnd Try to put the data directly into a file with something like this : FileWrite("Test.txt", _runSshCommand($unixUser, $unixHost, $sshCommand, $unixPassword)) So I can get the real data you obtain... Edited April 14 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
nicknuke Posted February 23, 2022 Author Posted February 23, 2022 8 hours ago, Nine said: Well the data you gave me is probably not the one you get from. Because it working fine with me... #include <Constants.au3> #include <GUIConstants.au3> #include <FontConstants.au3> $Form1 = GUICreate("Form1", 835, 634, 622, 236) $Edit1 = GUICtrlCreateEdit("", 240, 24, 577, 561,BitOR( $ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY)) GUICtrlSetFont(-1, 10, $FW_NORMAL, $GUI_FONTNORMAL, "Lucida Console") $showleasebtn = GUICtrlCreateButton("Read txt", 56, 72, 107, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $showleasebtn $answer = FileRead("output-autoit.txt") GUICtrlSetData($Edit1,$answer & @CRLF) MsgBox(0,"SSH Output", $answer) EndSwitch WEnd Try to put the data directly into a file with something like this : FileWrite("Test.txt", _runSshCommand($unixUser, $unixHost, $sshCommand, $unixPassword)) So I can get the real data you obtain... output-autoit.txt 307 B · 0 downloads Yes.. your idea of send the output to file helps. ( Sorry i sent you the wrong text file before.. ) I finally managed to spot the problem, pretty much like what Zedna said.. On 2/22/2022 at 4:02 AM, Zedna said: I think that problem is LF as end of line in your output but for EditBox you need CRLF. the editbox expected CRLF'ed input.. while the output from ssh server is just LF.. If I dump the output like you said like this : FileWrite("Test.txt", _runSshCommand($unixUser, $unixHost, $sshCommand, $unixPassword)) and check the Test.txt, the format detected as Unix Text (LF).. I have to convert it to DOS Text (CRLF) first.., then re-read the file in to editbox.. Then only after that i got perfect output.. I re-send you the original Unix text.. i hope it doesn't get converted automatically here... It supposed to show you the same garbled text on editbox. Thank you very much for the clues... So next question is.. What should I do to make the editbox receive the output in realtime , without putting it to a file and convert first ? Test-UnixText.txt
Nine Posted February 23, 2022 Posted February 23, 2022 Just convert your @LF with @CRLF : $answer = StringReplace(FileRead("Test-UnixText.txt"), @LF, @CRLF) Working for me “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
nicknuke Posted February 23, 2022 Author Posted February 23, 2022 2 hours ago, Nine said: Just convert your @LF with @CRLF : $answer = StringReplace(FileRead("Test-UnixText.txt"), @LF, @CRLF) Working for me Yes it is.. I was using StringRegExpReplace(FileRead("Test-UnixText.txt"), '\R', @CRLF) But yours are more simple and obvious... Thank you very much for the helps, sir...
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