Torque Posted March 13, 2006 Share Posted March 13, 2006 Hello all, I'm a newbie and I try to understand scripting in autoIt but I still need help. I try to write a few lines of text in a TXT file before the output of a binary (Doshashcalc.exe). FileOpen ($SOfile , 1) FileWriteLine ($SOfile , "Résultat du calcul à l'aide du programme Hashcalc:") RunWait (@ComSpec & " /c " & "bin\Doshashcalc.exe" & " -rz " & cquote(GuiCtrlRead($sdir)) & " > " & $SOfile , "." , @SW_HIDE) FileWriteLine ($SOfile , "Fin du processus de calcul") FileClose ($SOfile) This code doesn't work because the output of the binary, erases the first lines of the text file. Is there a way to keep the first lines at the begining of the file ? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 13, 2006 Moderators Share Posted March 13, 2006 Hello all, I'm a newbie and I try to understand scripting in autoIt but I still need help. I try to write a few lines of text in a TXT file before the output of a binary (Doshashcalc.exe). FileOpen ($SOfile , 1) FileWriteLine ($SOfile , "Résultat du calcul à l'aide du programme Hashcalc:") RunWait (@ComSpec & " /c " & "bin\Doshashcalc.exe" & " -rz " & cquote(GuiCtrlRead($sdir)) & " > " & $SOfile , "." , @SW_HIDE) FileWriteLine ($SOfile , "Fin du processus de calcul") FileClose ($SOfile) This code doesn't work because the output of the binary, erases the first lines of the text file. Is there a way to keep the first lines at the begining of the file ? Jdeb just made an example similar to this here: http://www.autoitscript.com/forum/index.ph...ndpost&p=160854 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...
Danny35d Posted March 13, 2006 Share Posted March 13, 2006 (edited) Hello all, I'm a newbie and I try to understand scripting in autoIt but I still need help. I try to write a few lines of text in a TXT file before the output of a binary (Doshashcalc.exe). FileOpen ($SOfile , 1) FileWriteLine ($SOfile , "Résultat du calcul à l'aide du programme Hashcalc:") RunWait (@ComSpec & " /c " & "bin\Doshashcalc.exe" & " -rz " & cquote(GuiCtrlRead($sdir)) & " > " & $SOfile , "." , @SW_HIDE) FileWriteLine ($SOfile , "Fin du processus de calcul") FileClose ($SOfile) This code doesn't work because the output of the binary, erases the first lines of the text file. Is there a way to keep the first lines at the begining of the file ? Try this... FileOpen ($SOfile , 1) FileWriteLine ($SOfile , "Résultat du calcul à l'aide du programme Hashcalc:") RunWait (@ComSpec & " /c " & "bin\Doshashcalc.exe" & " -rz " & cquote(GuiCtrlRead($sdir)) & " > " & @TempDir & "\DosHashCalc.txt", "." , @SW_HIDE) RunWait(@ComSpec & " /c & "Type " & @TempDir & "\DosHashCalc.txt" & " >> " & $SOfile, ".", @SW_HIDE) FileWriteLine ($SOfile , "Fin du processus de calcul") FileClose ($SOfile) Edit: Smoke_N type faster than me... Edited March 13, 2006 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
Torque Posted March 14, 2006 Author Share Posted March 14, 2006 Thank you for your very quick answer to my question Danny35d and SmOke_N. I worked with your help on my script and here's the result : FileOpen ($SOfile , 1) FileWriteLine ($SOfile , "Résultat du calcul à l'aide du programme DosHashcalc:") RunWait (@ComSpec & " /c " & "bin\DosHashcalc.exe" & " -rz " & cquote(GuiCtrlRead($sdir)) & " > " & @TempDir & "\transit.txt", "." , @SW_HIDE) $trans1 = FileRead (@TempDir & "\transit.txt", 200) FileWrite ($SOfile, $trans1) FileWriteLine ($SOfile , "Fin du processus de calcul") FileClose ($SOfile) It works ! But with only the first 200 characters of the transit.txt file. In fact I don't know how to make the FileRead function read the whole file instead of a fixed number of characters. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 14, 2006 Moderators Share Posted March 14, 2006 (edited) Thank you for your very quick answer to my question Danny35d and SmOke_N. I worked with your help on my script and here's the result : FileOpen ($SOfile , 1) FileWriteLine ($SOfile , "Résultat du calcul à l'aide du programme DosHashcalc:") RunWait (@ComSpec & " /c " & "bin\DosHashcalc.exe" & " -rz " & cquote(GuiCtrlRead($sdir)) & " > " & @TempDir & "\transit.txt", "." , @SW_HIDE) $trans1 = FileRead (@TempDir & "\transit.txt", 200) FileWrite ($SOfile, $trans1) FileWriteLine ($SOfile , "Fin du processus de calcul") FileClose ($SOfile) It works ! But with only the first 200 characters of the transit.txt file. In fact I don't know how to make the FileRead function read the whole file instead of a fixed number of characters. Do you have to use the RunWait() that your using, if so, what is the purpose... If not, why/where did you get this from out of curiousity? Sorry... FileRead was a question: FileRead('FilePath', FileGetSize(FilePath)) Edited March 14, 2006 by SmOke_N 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...
Torque Posted March 14, 2006 Author Share Posted March 14, 2006 Do you have to use the RunWait() that your using, if so, what is the purpose... If not, why/where did you get this from out of curiousity? Sorry... FileRead was a question: FileRead('FilePath', FileGetSize(FilePath)) Thank you again SmOke_N, Now it works perfectly with different files sizes. In fact a friend of mine helped me to create the original program. This little piece of code is coming from a tool I use to compute Tiger hashes. I need to run an external program to compute simultaneously several hashes on files larger than 2 Gb so it can take a lot of time. I don't want that the process stopped before the end of the files ... (it can be difficult to know if you miss something afterwards when you have thousands of hashes). I appreciate a lot your availability. Torque Link to comment Share on other sites More sharing options...
Confuzzled Posted March 14, 2006 Share Posted March 14, 2006 ShouldRunWait (@ComSpec & " /c " & "bin\Doshashcalc.exe" & " -rz " & cquote(GuiCtrlRead($sdir)) & " > " & $SOfile , "." , @SW_HIDE)beRunWait (@ComSpec & " /c " & "bin\Doshashcalc.exe" & " -rz " & cquote(GuiCtrlRead($sdir)) & " >> " & $SOfile , "." , @SW_HIDE)The double >> concatenates (adds) the results of Doshashcalc.exe to the end of the file, rather than creates a new one.Couldn't you do this with a batch file, using FOR, ECHO, >>, and parameter passing? Link to comment Share on other sites More sharing options...
Torque Posted March 14, 2006 Author Share Posted March 14, 2006 ShouldRunWait (@ComSpec & " /c " & "bin\Doshashcalc.exe" & " -rz " & cquote(GuiCtrlRead($sdir)) & " > " & $SOfile , "." , @SW_HIDE)beRunWait (@ComSpec & " /c " & "bin\Doshashcalc.exe" & " -rz " & cquote(GuiCtrlRead($sdir)) & " >> " & $SOfile , "." , @SW_HIDE)The double >> concatenates (adds) the results of Doshashcalc.exe to the end of the file, rather than creates a new one.Couldn't you do this with a batch file, using FOR, ECHO, >>, and parameter passing?Unfortunatly, the double >> doesn't work in my case (the output of Doshashcalc does not appear in the log file) and I don't know how to make such a batch file. Link to comment Share on other sites More sharing options...
Confuzzled Posted March 15, 2006 Share Posted March 15, 2006 http://www.microsoft.com/resources/documen...n-us/batch.mspx may assist with DOS commands.Where does Doshashcalc.exe put its output? Link to comment Share on other sites More sharing options...
neogia Posted March 15, 2006 Share Posted March 15, 2006 FileRead('FilePath') This works too, as the second parameter is optional. [u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 15, 2006 Moderators Share Posted March 15, 2006 FileRead('FilePath') This works too, as the second parameter is optional.Keep in mind when your talking to folks, you can't assume they have Beta, the second parameter even though it says 'optional', may in fact not be. 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...
neogia Posted March 15, 2006 Share Posted March 15, 2006 Keep in mind when your talking to folks, you can't assume they have Beta, the second parameter even though it says 'optional', may in fact not be. :"> Heh, I really should think of that more, I guess I don't realize how deeply having beta can affect a script. Oh and thanks for not being . [u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia 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