I’m having problems with this. It doesn’t seem to be working. Is it because of the double quotes around the “CheckVers=“YES”” & “CheckVers=“NO”” ?thanks
// store the file location
parameter “filename” = “{name of drive of system folder & “\pbapps\frates\fr.ini”}”
parameter “textToReplace” = “CheckVers=“YES””
parameter “newText” = “CheckVers=“NO””
// iterate through the file replacing lines as necessary
appendfile {concatenation “%0d%0a” of ( if (it contains (parameter “textToReplace”)) then ((preceding text of first (parameter “textToReplace”) of it) & (parameter “newText”) & (following text of first (parameter “textToReplace”) of it) ) else it ) of lines of file (parameter “filename”)}
So here’s the strange thing. I set it back to just “CheckVers=“YES”” & “CheckVers=“NO”” and in the bigfix log file, it shows the contents of the file that I am parsing (along with the correct NewText), however, the file that I am trying to modify never changes.
i’m trying to figure the best way to remove the unwanted CRLF at the end of a text file. I can see the CRLF there when I open the file in a text editor but when I search file the line in action script it doesnt seem to register … here’s the test I tried in the fixlet debugger.
if {exists lines whose (it contains “%0d%0a”) of file “C:\Program Files (x86)\BigFix Enterprise\BES Client\textfile.txt”}
appendfile TRUE
else
appendfile FALSE
endif
this gives me a blank in Q&A which must be the CRLF so the debugger can see it …
line (number of lines of it) of file "C:\Program Files (x86)\BigFix Enterprise\BES Client\Inv_scan_files\textfile.txt
and (number of lines of it) of file "C:\Program Files (x86)\BigFix Enterprise\BES Client\Inv_scan_files\textfile.txt gives me the line number of the line at the end that just has a CRLF
hi jesse, yes i was using the last example ( number of lines ) to demonstrate that the last line wwas indeed the CRLF and not any actual text. I just want to remove the CRLF from the last line ideally.
{concatenation “%0D%0A” of (if (line number of item 1 of it = item 0 of it AND item 1 of it ends with “%0D%0A”) then (preceding text of last “%0D%0A” of item 1 of it) else (item 1 of it)) of (number of lines of it, lines of it) of file “c:\foo.txt”}