Jump to content

Recommended Posts

Posted

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/

Posted

Use function StringInStr. Something like

If StringInStr($string, $substring) > 0 Then FileWriteLine(...)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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.

Posted

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.

Posted

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

Posted

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.

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
  • Recently Browsing   0 members

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