• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [OT] UNIX heads; can I do this?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [OT] UNIX heads; can I do this?


  • Subject: Re: [OT] UNIX heads; can I do this?
  • From: Marc Myers <email@hidden>
  • Date: Thu, 14 Jun 2007 00:41:22 -0400

I'm not really up on all of this shell scripting stuff, but it's pretty simple in Vanilla AppleScript:

set cr to ASCII character 13
set lf to ASCII character 10

set theFile to (choose file of type "TEXT") as text

try
	set fileRef to (open for access file theFile)
	set theText to read fileRef
	close access fileRef
on error errMsg number errNbr
	try
		close access fileRef
	end try
	error errMsg number errNbr
end try

set {od, AppleScript's text item delimiters} to ¬
	{AppleScript's text item delimiters, cr}
set theText to text items of theText
set AppleScript's text item delimiters to lf
set theText to theText as text
set AppleScript's text item delimiters to od

try
	set fileRef to open for access file theFile ¬
		with write permission
	set eof fileRef to 0
	write theText to fileRef starting at eof
	close access fileRef
on error errMsg number errNbr
	try
		close access fileRef
	end try
	error errMsg number errNbr
end try
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Prev by Date: QuarkXPress Script
  • Next by Date: Re: [OT] UNIX heads; can I do this?
  • Previous by thread: QuarkXPress Script
  • Next by thread: talking to external MySQL servers
  • Index(es):
    • Date
    • Thread