RomanY Posted January 6, 2018 Posted January 6, 2018 Hi guys, can you please help me! I run cmd and some special script which compare two files and than I see results in console. How can I get text from cmd and compare it with some expected result, with a help of Autoit? Thanks & Regards, Roman Y
water Posted January 6, 2018 Posted January 6, 2018 Welcome to AutoIt and the forum! Please provide - at least - what you have coded in AutoIt so far. How do you run the Cmd? Can you give an example of the returned results etc. etc. The more information you provide, the more answers you will get My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
RomanY Posted January 6, 2018 Author Posted January 6, 2018 Let's take for example command: ipconfig and I want to make some verification that my ip address: IPv4 Address. . . . . . . . . . . : 192.168.1.2 How to make some assert or another comparison with expected result?
water Posted January 6, 2018 Posted January 6, 2018 Use Run and redirect the output to StdOut. The help file provides an example here https://www.autoitscript.com/autoit3/docs/functions/StdoutRead.htm My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted January 6, 2018 Posted January 6, 2018 Example: Local $iPID = Run(@ComSpec & ' /C ipconfig', "", @SW_HIDE, $STDOUT_CHILD) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. Local $sOutput = StdoutRead($iPID) Variable $sOutput now holds the results of ipconfig. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
RomanY Posted January 6, 2018 Author Posted January 6, 2018 Thank you, it is better! Now, I want to check that I have exactly that ip address from all that output, for example I write _Assert($sOutput, '192.168.2.4') But it compare all output result and of course I receive failed assert. How can I check that in output result there should be my expected result?
water Posted January 6, 2018 Posted January 6, 2018 Quick and dirty! If StringInStr($sOutput, "192.168.2.4") > 0 Then MsgBox(0, "IP-address", "IP-Address found!") Else MsgBox(0, "IP-address", "IP-Address not found!") EndIf My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
RomanY Posted January 6, 2018 Author Posted January 6, 2018 4 minutes ago, water said: Quick and dirty! If StringInStr($sOutput, "192.168.2.4") > 0 Then MsgBox(0, "IP-address", "IP-Address found!") Else MsgBox(0, "IP-address", "IP-Address not found!") EndIf @water Very big thanks! You are really help me to solve my problem! I just have no experience yet, and want to work with autoit, and some times even to find simple answer on my questions it is hard because of lack of knowledge working with Autoit Help.
water Posted January 6, 2018 Posted January 6, 2018 (edited) Glad to be of service Next step would be to replace ipconfig with an approach that only returns the IP-address. WMI would be the way to go. In the example scripts section you will find "Scriptomatic". This script generates AutoIt code to query WMI. Edited January 6, 2018 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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