Cyborg5000 Posted February 14, 2022 Share Posted February 14, 2022 Iam trying to automate a few things is there any provision of increasing the names/numbers like example if the last host name was used as vw-aus-bl004 based on the count of provisioning i would like to have next 4 sets of host names.. Like vw-aus-bl005 vw-aus-bl006 vw-aus-bl007 vw-aus-bl008 and further...till 900 Link to comment Share on other sites More sharing options...
mLipok Posted February 14, 2022 Share Posted February 14, 2022 (edited) My crystal ball said to me: Yes. This is possible. But can you talk a little more about what you are trying to do, and which features you want to use ? Edited February 14, 2022 by mLipok Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Cyborg5000 Posted February 14, 2022 Author Share Posted February 14, 2022 Thanks @mLipok for helping and replying to this topic.....appreciate your help and time... Iam trying to get get vm provisioning a bit simpler using browser to read the requirements and the form that user submits. like cpu, ram, hdd and the count of vm's required. Using this information, and powershell i would be checking the host names used for that particular Business unit on the exsi once i get this info, with another script i need to have host names further that can be used....like the example above if the last host name was used as vw-aus-bl004 based on the count of provisioning i would like to have next 4 sets of host names.. Like vw-aus-bl005 vw-aus-bl006 vw-aus-bl007 vw-aus-bl008 Link to comment Share on other sites More sharing options...
Nine Posted February 14, 2022 Share Posted February 14, 2022 Try this : #include <Array.au3> Local Const $PREFIX = "vw-aus-bl" Local $iCurrent = 4 Local $aName = GenerateHostNames($iCurrent, 5) _ArrayDisplay($aName) Func GenerateHostNames(ByRef $iLast, $iNumber) Local $aHost[$iNumber] For $i = 0 To $iNumber - 1 $iLast += 1 $aHost[$i] = $PREFIX & StringFormat("%03i", $iLast) Next Return $aHost EndFunc “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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
mLipok Posted February 14, 2022 Share Posted February 14, 2022 (edited) My proposal was: Func _Generate($sCurrentName, $iNumberOfNewNames) Local Const $sBaseName = 'vw-aus-bl' Local $iCurrentNameNumer = Number(StringTrimLeft($sCurrentName, StringLen($sBaseName))) Local $sResult For $i = 1 To $iNumberOfNewNames $sResult = (($sResult) ? ("|") : ()) & $sBaseName & StringFormat("%03i", ( $iCurrentNameNumer + $i)) Next Return $sResult EndFunc Now @Cyborg5000 it is your turn to mix them Edited February 14, 2022 by mLipok Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Cyborg5000 Posted February 14, 2022 Author Share Posted February 14, 2022 Thanks a lot @mLipok and @Nine Link to comment Share on other sites More sharing options...
Cyborg5000 Posted February 15, 2022 Author Share Posted February 15, 2022 (edited) On 2/14/2022 at 10:19 PM, mLipok said: My proposal was: Func _Generate($sCurrentName, $iNumberOfNewNames) Local Const $sBaseName = 'vw-aus-bl' Local $iCurrentNameNumer = Number(StringTrimLeft($sCurrentName, StringLen($sBaseName))) Local $sResult For $i = 1 To $iNumberOfNewNames $sResult = (($sResult) ? ("|") : ()) & $sBaseName & StringFormat("%03i", ( $iCurrentNameNumer + $i)) Next Return $sResult EndFunc Now @Cyborg5000 it is your turn to mix them Getting error running the above code.... (6,43) : error: syntax error $sResult = (($sResult) ? ("|") : () ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ Edited February 15, 2022 by Cyborg5000 Link to comment Share on other sites More sharing options...
Cyborg5000 Posted February 15, 2022 Author Share Posted February 15, 2022 (edited) What i had in mind was that with powercli i can retrieve the host names that were previously used....on the esxi/VC. Further with the list of host names, i will take only the last hostname and with a script i will further generate the next required host names.... (The name keeps changing as per region, ISR, AUS, TELA, TELH, IND)...so cant be static names... vw-aus-qa (QA) /vw-isr-qa/vw-isr-dv/vw-ind-dv / vw-ind-qa) vw-aus-dv (DEV) /vw-isr-qa/vw-isr-dv/vw-ind-dv / vw-ind-qa) vw-aus-sp (Support) /vw-isr-qa/vw-isr-dv/vw-ind-dv / vw-ind-qa) vw-aus-bl (Build) /vw-isr-qa/vw-isr-dv/vw-ind-dv / vw-ind-qa) Even the no# arent specific....they may go to vw-aus-qa104 or vw-isr-dv300 or vw-isr-qa456 Edited February 15, 2022 by Cyborg5000 Link to comment Share on other sites More sharing options...
Cyborg5000 Posted February 15, 2022 Author Share Posted February 15, 2022 On 2/14/2022 at 10:15 PM, Nine said: Try this : #include <Array.au3> Local Const $PREFIX = "vw-aus-bl" Local $iCurrent = 4 Local $aName = GenerateHostNames($iCurrent, 5) _ArrayDisplay($aName) Func GenerateHostNames(ByRef $iLast, $iNumber) Local $aHost[$iNumber] For $i = 0 To $iNumber - 1 $iLast += 1 $aHost[$i] = $PREFIX & StringFormat("%03i", $iLast) Next Return $aHost EndFunc The above code works like a charm, but the prefix is static in the code, the hostnames/regions aren't and i get the host names from the form and VC (the last host name that was used) Link to comment Share on other sites More sharing options...
mLipok Posted February 15, 2022 Share Posted February 15, 2022 36 minutes ago, Cyborg5000 said: Getting error running the above code.... (6,43) : error: syntax error $sResult = (($sResult) ? ("|") : () ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ Which version of AutoIt you are using ? Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Cyborg5000 Posted February 15, 2022 Author Share Posted February 15, 2022 3 minutes ago, mLipok said: Which version of AutoIt you are using ? Version 3.4.4 Link to comment Share on other sites More sharing options...
Cyborg5000 Posted February 15, 2022 Author Share Posted February 15, 2022 (edited) 5 minutes ago, Cyborg5000 said: Version 3.4.4 (This version is only for lazy mind and using only for au3 recorder...) i tried using combinations from below example and few others like DO until etc.....but came to a stop not knowing what options or ways i have.... 😭 Edited February 15, 2022 by Cyborg5000 Link to comment Share on other sites More sharing options...
Cyborg5000 Posted February 15, 2022 Author Share Posted February 15, 2022 This code is exactly what should work for me... but unsure how to or where to put the last host name captured from the VC, and the count of the host's to be incremented as per the requirement.. Link to comment Share on other sites More sharing options...
Nine Posted February 15, 2022 Share Posted February 15, 2022 57 minutes ago, Cyborg5000 said: but the prefix is static in the code, the hostnames/regions aren't Well your initial post didn't say that hostname prefixes would vary in time. And for what it is worth, it doesn't change much of the code I gave you, you just need to adapt it to your needs. If you cannot do that by yourself, hmmm, I would suggest you delegate the programming to someone else. Exit 1 “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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Cyborg5000 Posted February 16, 2022 Author Share Posted February 16, 2022 8 hours ago, Nine said: Well your initial post didn't say that hostname prefixes would vary in time. And for what it is worth, it doesn't change much of the code I gave you, you just need to adapt it to your needs. If you cannot do that by yourself, hmmm, I would suggest you delegate the programming to someone else. Hi Thanks and appreciate you for responding back to this @Nine Yeah my bad, i should had said that only the 1st prefix is static VW- (Virtual Windows) and VL- (Virtual Linux). iam looking for pointers or may be a help in how can i achieve in getting further host names once i get the last host name being used on the VC based on the region. The code used below works like a charm when testing with the host names that are being used.... Link to comment Share on other sites More sharing options...
Cyborg5000 Posted February 16, 2022 Author Share Posted February 16, 2022 1 minute ago, Cyborg5000 said: Hi Thanks and appreciate you for responding back to this post🙏@Nine Yeah my bad, i should had said that only the 1st prefix is static VW- (Virtual Windows) and VL- (Virtual Linux). iam looking for pointers or may be a help in how can i achieve in getting further host names once i get the last host name being used on the VC based on the region. The code used below works like a charm when testing with the host names that are being used....only the thing is that it can generate 1 host at a time when clipget is active/having a host name..... 🤔 Link to comment Share on other sites More sharing options...
Cyborg5000 Posted February 16, 2022 Author Share Posted February 16, 2022 The exact host names used are vw-aus-dombl001 vw-aus-zsodv001 Link to comment Share on other sites More sharing options...
Cyborg5000 Posted February 16, 2022 Author Share Posted February 16, 2022 @Nine and @mLipok Thanks to both of you for your help and directives... was able to achieve mixing your code and below code...🙏✌️ Link to comment Share on other sites More sharing options...
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