Sam1el Posted October 19, 2012 Share Posted October 19, 2012 I've tried to write as much of my script as possible without asking for help but i'm stuck. I've searched the forums for my answer and read the help files but not totally sure how to go about my final step. THe code reads a file in a specified drive and writes a log to a server. What I need to add is, I need it to look for a specific word and then write the file if the word is present and not write the file if it isn't. I am sure it's a simple if/elsif and exit but not sure how to approach it. here's a snippet. Select Case @OSVersion = "WIN_XP" If FileExists("C:\Documents and Settings\All Users\Application Data\DassaultSystemes\CATEnv\Teamcenter_Integration_for_CATIAV5.txt") Then FileReadLine('C:\Documents and Settings\All Users\Application Data\DassaultSystemes\CATEnv\Teamcenter_Integration_for_CATIAV5.txt', 10) $PCName = @ComputerName $file = FileOpen("\\server\SCCM_Logs\" & $PCName & "log.txt", 1) ; Write month/day @ time FileWrite($file, @MON & "/" & @MDAY & " @ " & @HOUR & ":" & @MIN & " - ") ; Write computer name along with text FileWrite($file, $PCName & " - " & "File Exists") ; go to next line FileWrite($file, @CRLF) FileClose($file) Exit EndIf EndSelect i'm super close to what I need. THe word i'm looking for is Amro if that'll help/ Link to comment Share on other sites More sharing options...
water Posted October 19, 2012 Share Posted October 19, 2012 Use function StringInStr. Something like If StringInStr($string, $substring) > 0 Then FileWriteLine(...) My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Sam1el Posted October 22, 2012 Author Share Posted October 22, 2012 Tried to implement this bit I may be missing something. It will parse and write my file according to my defined line but still wot print if it finds the text I'm looking for. Link to comment Share on other sites More sharing options...
FireFox Posted October 22, 2012 Share Posted October 22, 2012 Hi, Maybe this : Select Case @OSVersion = "WIN_XP" If FileExists("C:Documents and SettingsAll UsersApplication DataDassaultSystemesCATEnvTeamcenter_Integration_for_CATIAV5.txt") Then $sLineData = FileReadLine('C:Documents and SettingsAll UsersApplication DataDassaultSystemesCATEnvTeamcenter_Integration_for_CATIAV5.txt', 10) If StringInStr($sLineData, "Amro") Then $PCName = @ComputerName $file = FileOpen("serverSCCM_Logs" & $PCName & "log.txt", 1) ; Write month/day @ time FileWrite($file, @MON & "/" & @MDAY & " @ " & @HOUR & ":" & @MIN & " - ") ; Write computer name along with text FileWrite($file, $PCName & " - " & "File Exists") ; go to next line FileWrite($file, @CRLF) FileClose($file) EndIf Exit EndIf EndSelect Br, FireFox. Link to comment Share on other sites More sharing options...
kylomas Posted October 22, 2012 Share Posted October 22, 2012 Sam1el,This script will only work if "Amro" exists on line 10 of the input file. Is this your intent?kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
JohnOne Posted October 22, 2012 Share Posted October 22, 2012 Tried to implement this bit I may be missing something. It will parse and write my file according to my defined line but still wot print if it finds the text I'm looking for.Be clear, it writes what, and where?Define print, and print what, and where? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Sam1el Posted October 23, 2012 Author Share Posted October 23, 2012 Yes! I would like it to only print the file if it finds the owrd amro and I woul dlike it appended to the name of the file. I am going to test the suggestions given. Thanks so much for your help and patience. caught a nasty staph infection on the business trip I just returned from and i'm half concious. 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