Im currently building a AppleScript Studio application that creates a series of set folders and creates 2 shell scripts . The problem is that the shell scripts do not get set with the correct linefeed. They are set to the Mac <CR> setting instead of the , correct in my case, setting.
set fileRef to (open for access alias scriptinstall with write permission)
write "#!/bin/sh" & return to fileRef as «class utf8» starting at eof
write "# Date:" & Thedate & return to fileRef as «class utf8» starting at eof
write "# Build by:" & BouwerNaam & return to fileRef as «class utf8» starting at eof
write "# " & return to fileRef as «class utf8» starting at eof
write "# This script installs :" & RadiaNaam & ". Logfile located at /var/log/radia/" & RadiaNaam & ".log" & return to fileRef as «class utf8» starting at eof
write "# " & return to fileRef as «class utf8» starting at eof
write "# Installationline:" & return to fileRef as «class utf8» starting at eof
write return to fileRef as «class utf8» starting at eof
write "/usr/sbin/installer -pkg /Library/Radia/package/" & RadiaNaam & ".pkg " & "-target / -allow -verboseR >>/var/log/radia/" & RadiaNaam & ".log" & return to fileRef as «class utf8» starting at eof
write return to fileRef as «class utf8» starting at eof
close access fileRef
I've found the following at macscripter.net:
I've followed the second example and created the following routine:
set txt to " #!/bin/sh" & return & "# Aanmaakdatum:" & Thedate & return & "# Script build by:" & BouwerNaam & return & "# " & return & "# This script installs:" & RadiaNaam & ". Logfile located at /var/log/radia/" & RadiaNaam & ".log" & return & "# " & return & "# installation line" & return & "/usr/sbin/installer -pkg /Library/Radia/package/" & RadiaNaam & ".pkg " & "-target / -allow -verboseR >>/var/log/radia/" & RadiaNaam & ".log"
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to ASCII character 10 -- (a line feed)
set newTxt to text items of txt -- not text of, text items of
set AppleScript's text item delimiters to tid -- whatever they were before - ALWAYS SET THEM BACK!
set fileRef to (open for access alias scriptinstall with write permission)
write newTxt to fileRef starting at eof
close access fileRef
The script does work, however the linefeed is still set to Mac <CR>... And to open all the scripts build by the application using TextWrangler in order to set them correct is not really a option... Building around a 60 to a 100 unix scripts a month....
Does someone know what to do? And what to change?
Thank you in advance.