Erlend Posted November 16, 2009 Posted November 16, 2009 Helloi have created a small application that collects varius information in a txt file, the txt file looks like this:user input inn the application is username, and the information i need to get out is the data from SessionName and ServerNameso if i input User2 in my application i need to return data about SessionName and ServerName, i have looked at using FIND to return the line number and the use filereadlin to read this line + 1 and + 3 but i haven´t got it to work yetthe data that FIND returns if i use this is: [11]UserName : User2 so if i could get filereadline to read a line number based on that FIND returns the problem is solved.expandcollapse popupname : 57a8:3:APP1 host : SERVER1 zone : 192.168.1.0 Version[Session] : 1 ProductType : 12 SessionId : 3 ClientName : WI_HDYctb6leGHTXIFAL UserName : User1 SessionName : ICA-tcp#107 LogonTime : 0000-0124-fe040e07 ServerName : SERVER1 AppName : APP1 SessionConnectionType : 1 ClientNameIndex : WI_HDYctb6leGHTXIFAL DomainUserNameIndex : DomainX\User1 HostId : 22440 UserDomain : DomainX Protocols : 1 DataType : 1 ServerType : 1 ClientType : 1 LaunchedBrowserName : APP1 InitialBrowserName : APP1 SessionState : 0 FullyQualifiedCredentials : DomainX\User1 SessionAuthenticationType : NT 00080022 : 0 AccessSessionGuid : IsLastSessionApp : 1 DeviceId : LogonString : DomainX\User1 UPN : \User1@DomainX.LOCAL ADSDomain : \User1@DomainX.LOCAL name : 2553:1:APP1 host : SERVER2 zone : 192.168.1.0 Version[Session] : 1 ProductType : 12 SessionId : 1 ClientName : WI_ERnNBwRAfAsLlnd7O UserName : User2 SessionName : ICA-tcp#36 LogonTime : 0000-0124-fe03f58d ServerName : SERVER2 AppName : APP1 SessionConnectionType : 1 ClientNameIndex : WI_ERnNBwRAfAsLlnd7O DomainUserNameIndex : DomainX\User2 HostId : 9555 UserDomain : DomainX Protocols : 1 DataType : 1 ServerType : 1 ClientType : 1 LaunchedBrowserName : APP1 InitialBrowserName : APP1 SessionState : 0 FullyQualifiedCredentials : DomainX\User2 SessionAuthenticationType : NT 00080022 : 0 AccessSessionGuid : IsLastSessionApp : 1 DeviceId : 00080027 : DomainX\User2 LogonString : DomainX\User2 UPN : \User2@DomainX.LOCAL ADSDomain : \User2@DomainX.LOCALThanks for any help
Moderators Melba23 Posted November 16, 2009 Moderators Posted November 16, 2009 Erlend, This is one way of doing it. #include <File.au3> $sFilename = "Your_File_Path" Global $aFileLines[1] _FileReadToArray($sFilename, $aFileLines) While 1 $sUser = InputBox("User", "Input User name (blank to exit)") If $sUser = "" Then Exit For $i = 1 To $aFileLines[0] If StringinStr($aFileLines[$i], $sUser, 1) Then $aTemp = StringSplit($aFileLines[$i], ":") $sName = StringStripWS($aTemp[2], 3) $aTemp = StringSplit($aFileLines[$i + 1], ":") $sSessionName = StringStripWS($aTemp[2], 3) $aTemp = StringSplit($aFileLines[$i + 3], ":") $sServerName = StringStripWS($aTemp[2], 3) ConsoleWrite($sName & " - " & $sSessionName & " - " & $sServerName & @CRLF) ExitLoop EndIf Next WEnd This works on the test data you provided. If that is modified in any way you will, of course, need to modify this script accordingly. I have also not included any errorchecking which I strongly advise (incorrect Username entered, UserName not found, etc). No doubt an SRE guru will be along in a minute with a wonderful pattern. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Erlend Posted November 16, 2009 Author Posted November 16, 2009 Thanks i will trie this, for now i have managed to resolve it by making a query by username, when the information is collected.
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