Sign in to follow this  
Followers 0
gcue

Log Grabber

5 posts in this topic

im trying to put together an app that can read from an ini file the locations of log files for any given application.

here's what i mean:

if a person reports an issue with a software and i need to get their log files for that application, i would like to be able to read from an ini that somewhat resembles this:

[LOGS]

app1=<logfilel1_location>, <logfile2_location>

app2=<logfilelocation>

app3=<logfilel1_location>, <logfile2_location>,<logfile3_location>

[PC]

username1=<pc_serial number>

username2=<pc_serial number>

so if user2 calls with an issue with app1, i can choose user2 and app1 from a dropdown of some sort and have his log files instantly!

i was thinking of even using wzzip (winzip's commandline utility) for multiple log files for the same application

any ideas?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

This is a very quick & dirty script but it will give you ideas:

#include <GUIConstants.au3>

Dim $iniFile = "test.ini"
Dim $aPC = IniReadSection ($iniFile , "PC")
Dim $aApps = IniReadSection ($iniFile , "LOGS")

GUICreate("My GUI")  ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)       ; will display an empty dialog box

;PC---------------------
GUICtrlCreateLabel("Users", 10, 10)
$PC_list = GUICtrlCreateList ("", 10, 30,180,240)

For $X = 1 to $aPC[0][0]
    GUICtrlSetData ($PC_list, $aPC[$X][0])
Next

;Apps-------------------
GUICtrlCreateLabel("Apps", 210, 10)
$Apps_list = GUICtrlCreateList ("", 210, 30,180,240)

For $X = 1 to $aApps[0][0]
    GUICtrlSetData ($Apps_list, $aApps[$X][0])
Next

;Serial-----------------
GUICtrlCreateLabel("Serial", 10, 280)
$serial_input = GUICtrlCreateInput("", 10, 300, 180)

;Available logs-----------------
GUICtrlCreateLabel("Available logs", 210, 280)
$FOUND_list = GUICtrlCreateList ("", 210, 300,180, 95)

; Run the GUI until the dialog is closed
While 1
    Switch GUIGetMsg()
        ;Close action
        Case $GUI_EVENT_CLOSE
            ExitLoop
        ;Click within user / pc list
        Case $PC_list
            populate_serial()
        ;Click within LOGS / Apps list
        Case $Apps_list
            populate_available()
        ;Click within log filenames list
        Case $FOUND_list
            ShellExecute(GuiCtrlRead($FOUND_list))
    EndSwitch
Wend

Func populate_serial()
    GUICtrlSetData($serial_input, "")
    
    ;Find ini key in original array
    For $X = 1 to $aPC[0][0]
        If $aPC[$X][0] = $current Then
            GUICtrlSetData($serial_input, $aPC[$X][1])
        EndIf
    Next
EndFunc

Func populate_available()
    GUICtrlSetData($FOUND_list, "")
    
    $current = GuiCtrlRead($Apps_list)
    
    ;Find ini key in original array
    For $X = 1 to $aApps[0][0]
        If $aApps[$X][0] = $current Then
            $aTemp = StringSplit($aApps[$X][1], ",")
            For $X = 1 to $aTemp[0]
                GUICtrlSetData($FOUND_list, $aTemp[$X])
            Next
        EndIf
    Next
EndFunc
Edited by weaponx

Share this post


Link to post
Share on other sites

thanks weapon!

i am trying to populate the asset field for each user PC (as specified in the INI)

im also trying to set in an autoscroll feature for entries that fall out of the specified space range

here is a screenshot to better illustrate what i'm describing:

http://www.postyourimage.com/view_image.ph...hRcsw1208960284

INI:

[LOGS]
Altiris="c:\program files\altiris\altiris agent\logs\agent.log"
Notes="c:\lotus\notes\data\fault_recovery.log","u:\apps\notes\data\fault_recovery.log"

[ASSETS]
PC1=192.169.0.1
PC2=192.168.0.2

Share this post


Link to post
Share on other sites

Well that example INI is not the same as the first example you posted...this will work with your current example.

#include <GUIConstants.au3>

Dim $iniFile = "test.ini"
Dim $aPC = IniReadSection ($iniFile , "ASSETS")
Dim $aApps = IniReadSection ($iniFile , "LOGS")

GUICreate("My GUI")  ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)       ; will display an empty dialog box

;PC---------------------
GUICtrlCreateLabel("Users", 10, 10)
$PC_list = GUICtrlCreateList ("", 10, 30,180,240)

For $X = 1 to $aPC[0][0]
    GUICtrlSetData ($PC_list, $aPC[$X][0])
Next

;Apps-------------------
GUICtrlCreateLabel("Apps", 210, 10)
$Apps_list = GUICtrlCreateList ("", 210, 30,180,240)

For $X = 1 to $aApps[0][0]
    GUICtrlSetData ($Apps_list, $aApps[$X][0])
Next

;Asset-----------------
GUICtrlCreateLabel("Asset", 10, 280)
$serial_input = GUICtrlCreateInput("", 10, 300, 180)

;Available logs-----------------
GUICtrlCreateLabel("Available logs", 210, 280)
$FOUND_list = GUICtrlCreateList ("", 210, 300,180, 95)

; Run the GUI until the dialog is closed
While 1
    Switch GUIGetMsg()
        ;Close action
        Case $GUI_EVENT_CLOSE
            ExitLoop
        ;Click within user / pc list
        Case $PC_list
            populate_asset()
        ;Click within LOGS / Apps list
        Case $Apps_list
            populate_available()
        ;Click within log filenames list
        Case $FOUND_list
            ShellExecute(GuiCtrlRead($FOUND_list))
    EndSwitch
Wend

Func populate_asset()
    GUICtrlSetData($serial_input, "")
    
    $current = GuiCtrlRead($PC_list)
   
    ;Find ini key in original array
    For $X = 1 to $aPC[0][0]
        If $aPC[$X][0] = $current Then
            GUICtrlSetData($serial_input, $aPC[$X][1])
        EndIf
    Next
EndFunc

Func populate_available()
    GUICtrlSetData($FOUND_list, "")
   
    $current = GuiCtrlRead($Apps_list)
   
    ;Find ini key in original array
    For $X = 1 to $aApps[0][0]
        If $aApps[$X][0] = $current Then
            $aTemp = StringSplit($aApps[$X][1], ",")
            For $X = 1 to $aTemp[0]
                GUICtrlSetData($FOUND_list, $aTemp[$X])
            Next
        EndIf
    Next
EndFunc

Share this post


Link to post
Share on other sites

yep that worked!!

weird thing tho, when i select ETP for the logs, it sorta goes into a loop it seems and i cant get out of it unless i right click the icon in the sys tray and exit

[LOGS]
Altiris="c:\program files\altiris\altiris agent\logs\agent.log"
Notes="c:\lotus\notes\data\fault_recovery.log","u:\apps\notes\data\fault_recovery.log"
ETP="c:\Program Files\ETP\rolling.log"
[ASSETS]
JSR_ETP=d0056849
NFB_ETP=d0091117

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0