Handling files with lines delimited by LF

(imported topic written by SystemAdmin)

So… I have some java policies that I’m appending a permission within the “grant {” section to allow the use of the system clipboard. The issue with the file is that it’s delimited by LF, not CRLF.

I was able to handle the relevance to concatenate the lines correctly and insert the line in the right spot. My only issue is recreating the file correctly. Both appendfile and createfile add a CFLF after each use. I suppose it might not hurt the policy to have a CRLF at the end, but is there a better way (aside from a sleazy trick by piping out the DOS “type” command)?

Here’s to wishing appendfile and createfile had an optional parameter to specify a EOL delimiter.

Paul

Here’s a sniplet of my action. Makes no difference if it was createfile or appendfile for this example…

createfile until END_OF_FILE

{(concatenation “%0a” of lines whose (line number of it < minimum of line numbers of lines containing “}};” whose (line number of it > (line number of line containing “grant {” of file “C:\Program Files\Java\jre6\lib\security\java.policy”)) of file “C:\Program Files\Java\jre6\lib\security\java.policy”) of file “C:\Program Files\Java\jre6\lib\security\java.policy”) & “%0a%09permission java.awt.AWTPermission %22accessClipboard%22;%0a” & (concatenation “%0a” of lines whose (line number of it >= minimum of line numbers of lines containing “}};” whose (line number of it > (line number of line containing “grant {” of file “C:\Program Files\Java\jre6\lib\security\java.policy”)) of file “C:\Program Files\Java\jre6\lib\security\java.policy”) of file “C:\Program Files\Java\jre6\lib\security\java.policy”) & “%0a”}

END_OF_FILE

(imported comment written by NoahSalzman)

As a workaround you could post-process with something like FixCRLF:

http://ant.apache.org/manual/Tasks/fixcrlf.html

(imported comment written by SystemAdmin)

Yeah, I’m not too sure how I would use that in a Windows environment. I’m adjusting the java policies after pushing the latest Java JRE runtime to the workstations.

Paul

(imported comment written by NoahSalzman)

Windows version:

http://downloads.zdnet.com/abstract.aspx?docid=786863

(imported comment written by SystemAdmin)

Looks like that won’t work. Seems to be strictly a GUI application.

I’ll have to keep looking… :frowning: