Can files be read from the web or the cloud?
I am trying to read this file but get the file open error.
#include <FileConstants.au3> #include <MsgBoxConstants.au3> ;Assign the file path to a variable Local $sFilePath = "C:\Automation\test.txt" Local $sFilePathAzure ="https://batlgroupimages.blob.core.windows.net/files/test.txt" Local $nLineNumberToLookFor = 0 ;Open the file test.txt in append mode. ;If the folder C:\Automation does not exist, it will be created. Local $hFileOpen = FileOpen($sFilePathAzure, $FO_APPEND + $FO_CREATEPATH) ;Display a message box in case of any errors. If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred while opening the file.") EndIf ;Set the file position to beginning for reading the data from the beginning of the file. FileSetPos($hFileOpen, 0, $FILE_BEGIN) ;Read the data from the file using the handle returned by FileOpen ;Local $sFileRead = FileRead($hFileOpen) ;Read the 2nd line of data from the file using the handle returned by FileOpen Local $sFileReadLine = FileReadLine ($hFileOpen,2) ;Close the handle returned by FileOpen. FileClose($hFileOpen)
A programme I wrote for the organisation for which I work has been in use for a number of years with no issue. One of the things that it does is allow for attachments to be selected (Word docs, Excel sheets, etc) which it then writes away as a BLOB in MySQL.
This was all working fine until recently, when suddenly, on the odd occasion, Word would advise that the file was corrupt on retrieval of the BLOB from MySQL.
Upon further examination it appears that the issue is not with the retrieval of the data from MySQL, but reading in the data from the disk by AutoIT. It seems that on occasions that AutoIT will only read half the file.
I have no idea why this is, as the whole function is very simple. I have included a sanitised vesion of it below in the hope that someone can tell me where to look next, as this one has me beat (again). 😋
I have put some comments in to show what I have done to try and solve the problem, but am getting no closer to the truth. @error is the strangest one - it should return -1 when it reaches end of file but is returning zero.
Func _AttachAttachment() local $file,$chars,$fsize If $RFC_Retrieved = False Then msgbox(0,"Error","Must have a RFC active first") Else $file=FileOpenDialog("Attach to RFC",".","All (*.*)",1) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; FileClose($file) These two lines are my attempt to open the file in binary mode. Made no difference ; FileOpen($file,16) ; Read in the File $fsize = FileGetSize($file) ConsoleWrite("File size is " & $fsize & @CRLF) ; the size comes back as what it say in Windows properties ; $chars = FileRead($file,$fsize) ; I was using this, then tried the line following this. It didn't help $chars = FileRead($file) ; This is showing a figure $chars/2 - 1 I don't understand this ConsoleWrite("Number of chars read is " & @extended & " error code is " & @error & @crlf) ; @error is coming back with 0. I don't understand this as I thought it would be -1 FileClose($file) EndIf EndIf EndFunc Thanks in advance for looking at this
I've made a program that relies on IniReadSectionNames. It reads (~3K) Autorun.inf files in the working folder and creates a GUI based on their contents.
I made sure to revert to a default GUI upon @error.
But someone (with Windows XP SP3 32-bit) reported to me he always gets the default menu.
I sent him a FileRead command instead and it works! So seemingly there's no access problem to AutoRun.inf.
In the following demo code, I always hit success, but he always ends up with semi-success:
Local $hIniLocation = "Autorun.inf" Local $aSections = IniReadSectionNames($hIniLocation) If @error Then $aSections = FileRead($hIniLocation) if @error then msgbox(48, "Double error", "Alternative access failed too due to:" & @crlf & @error & @crlf & @extended) else msgbox(0, "Semi-success", "IniReadSectionNames failed, but alternativaly this file contains:" & @crlf & @crlf & $aSections) endif else msgbox(0, "Success", "IniReadSectionNames worked!") endif Why is that? Is there something further to check with him?
I ran a remote program on 180 computers and logged the output to a log file with paexec. I'm trying to parse through the log file to see which computers launched the program successfully and record the computer name but I'm not sure how to go about it.
I can successfully open the log file, read it but not sure how to start separating the data.
I've attached the log file, basically every computer entry in the log file for a new computer starts with "Connecting to <computername>..." I was thinking about using that as the start and stop point for retrieving the end results. Anything with a "returned 0" is a success, everything is a fail.
Any help is much appreciated.
This code will read text data from txt file. However, if I use '$Newtext &= $convert' then $convert is saved as strings, not hex value.
For example, if $convert = 0x300020FF and $bNewText = Test then the result is 0x333030303230464654657374. (Wrong)
What I want is 0x300020FF54657374. How can I modify my script?
For $i = $y-1 To Ubound($split) - 1 $convert = "0x" & $split[$i] $Newtext &= $convert $NewLen_hex = BinaryLen ($convert) $i=$i+1 $split[$i] = $split[$i] $split[$i] = StringRegExpReplace($split[$i], "<cf>", @CRLF) $split[$i] = StringRegExpReplace($split[$i], "<lf>", @LF) $split[$i] = StringRegExpReplace($split[$i], "<cr>", @CR) $bNewText = _WinAPI_WideCharToMultiByte($split[$i], $CP_SHIFT_JIS) if $i = Ubound($split) - 1 Then $bNewText &= Chr(0) EndIf $Newtext &= $bNewText $NewLen = $NewLen_hex + BinaryLen ($bNewText) Next (...) (...) $Newfile = BinaryMid($Newfile_header,1) & BinaryMid($Newtext,1) $hNewfile = FileOpen ("NEW_"&$Name, 2+16) FileWrite ($hNewfile, $Newfile) FileClose ($hNewfile) TrayTip ("Importer", "Finish!", 3) sleep (3000)