Jump to content

Reading a .txt and displaying its contents in a messagebox


Recommended Posts

Hello,

I'm sorry , I know this is a really basic question and I feel like an idiot for asking. I am currently writing a script that scans network machines, to check if cetain folders on the machine are populated with files(It lets us know if our ftp service is working correctly). I currently have it set up to add the name of the machine to a txt file if it cannot connect, and same if it can connect but the folder is poulated with 10 or more files. After it is done scanning the machines I want it to read these temporary txt files and display a box that says "Summary: [Enter] Cannot Connect to: [Enter] (then display the names from the text file [Enter] [Enter] Ftp service not active: [Enter] then display the names from the other file.

One problem that I have run into is that most of the time ther is no ftp problems so one of the txt files is not created.

#Include <File.au3>
#Include <Array.au3>
FileInstall("C:\Documents and Settings\OvittKe\My Documents\scripts\ADR\Names.txt", @ScriptDir & "\", 0)
$count = 0
$PC_File = FileOpen("Names.txt",0)
ProgressOn("ADR FTP SCAN", "Percent Complete", "Progress",1,16)
    $Line_Number = _FileCountLines("Names.txt")
    $Percent = ($count / $Line_Number) * 100
While True
        $Percent = ($count / $Line_Number) * 100
        ProgressSet($Percent)
        $CompName = FileReadLine($PC_File)
            If @error = -1 Then
                ExitLoop
            EndIf
                $count = $count+1
        $Files = _FileListToArray("\\"&$CompName&"\c$\adr\data")
        If @error = 1 Then
            $Files_Re = _FileListToArray("\\"&$CompName&"\c$\adr\data")
                If @error = 1 Then
                    $PingValue = ping($compName) 
                    If $PingValue = 0 Then
                        FileWriteLine ("Unable.txt", $CompName & @CRLF)
                    EndIf
                EndIf
        Else
            If @error <> 4 Then
                If $Files[0] >= 10 Then
                    FileWriteLine("FTPerror.txt", $CompName & @CRLF)
                EndIf
            EndIF
        EndIf
        

Wend
ProgressOff()
SoundPlay(@WindowsDir & "\media\tada.wav",0)
;FileOpen("Unable.txt",0)
;FileOpen("FTPerror.txt",0)
;$C_error = FileRead("Unable.txt")
;$FTP_error = FileRead("FTPerror.txt")
;MsgBox("Complete","The Scan has succesfully been completed." & @CRLF & "Summary:" & @CRLF & "Unable to connect to computers:" & @CRLF & $C_error & @CRLF & @CRLF & "Not Performing FTP Services:" & @CRLF & $FTP_error )
;FileDelete("Unable.txt")
;FileDelete("FTPerror.txt")

At the bottom I have attempted this and failed..

Please help! It is much appreciated!

Thanks! :)

[Edit]

I figured it out.. Thanks anyway :P

Edited by Kovitt
Link to comment
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
 Share

  • Recently Browsing   0 members

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