benoahriz Posted September 23, 2008 Share Posted September 23, 2008 I know this has probably been gone over a few times but the search function didnt reveal to me exactly what i was looking for. I am in the process of converting a bat script i use often. Part of what the script does is run multiple programs that have an outputted logfile. The script i wrote appends all the log files into one log file. What i was doing was using a win32 version of cat.exe to do it. This is an example of what the code used to look like. Runwait(@ComSpec & " /c " & 'cat.exe %tmplog1% >> %log% 2>&1', "", @SW_HIDE) In an effort to learn more about autoIT and make my script completely pure autoIT i need to figure out the syntax of this. I have tried many different things and think im close but i dont have it yet. It seems like a simple thing to me but again i think im getting the syntax wrong. Also i dont know if this makes a difference but im using the FileOpen() and FileWriteLine() functions throughout the script which may or may not affect trying to append a the same file? any help please would be appreciated. Even linking back to previous posts would be helpful. Shoutcast hosting Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 23, 2008 Moderators Share Posted September 23, 2008 As I said in the PM. ;Concat the two log files $s_concat = FileRead("FileOldLogThatAllDataIsWrittenToAlways") & @CRLF & FileRead("FileNewLog") ; Erase content of FileOldLogThatAllDataIsWrittenToAlways $h_open = FileOpen("FileOldLogThatAllDataIsWrittenToAlways", 2) ; Write the concated data FileWrite($h_open, $s_concat) ;Done FileClose($h_open) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
benoahriz Posted September 24, 2008 Author Share Posted September 24, 2008 That actually puts the data on the top of the file. Closer to what i need yet not exact. That does combine the files together but im looking for something that just appends a file. I tried using the same code in different ways to see if it would switch the order aroudn but that didnt work either. Also my intention is to do this over and over in the same script as log files from different programs are produced. But in a sequential order. Im kind of looking for the functionality of FileWriteLine() but for an entire file and then multiple files. Shoutcast hosting Link to comment Share on other sites More sharing options...
benoahriz Posted September 24, 2008 Author Share Posted September 24, 2008 (edited) I actually figured this out by myself. Thanks for the direction though. $file = FileOpen($log, 1) $v_tmplog1 = FileRead($tmplog2) FileWrite($file, $v_tmplog1) This does it more like 'cat' and 'echo' and '>>' Edited September 24, 2008 by benoahriz Shoutcast hosting Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 24, 2008 Moderators Share Posted September 24, 2008 I actually figured this out by myself. Thanks for the direction though. $file = FileOpen($log, 1)$v_tmplog1 = FileRead($tmplog2)FileWrite($file, $v_tmplog1)This does it more like 'cat' and 'echo' and '>>'Actually to append to the end of the file you could have just used a 1 liner: FileWrite(). Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
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