Jump to content

Recommended Posts

Posted

Hello

i 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 ServerName

so 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 yet

the 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.

name            : 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.LOCAL

Thanks for any help :)

  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

Thanks i will trie this, for now i have managed to resolve it by making a query by username, when the information is collected.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...