Re: Print text to Terminal
Re: Print text to Terminal
- Subject: Re: Print text to Terminal
- From: Barry Wainwright <email@hidden>
- Date: Fri, 20 May 2005 14:21:32 +0100
- Thread-topic: Print text to Terminal
On 18/5/05 8:51 pm, "has" <email@hidden> wrote:
> Second what Andrew says: use Console.app; that's what it's there for.
> Terminal.app is the wrong tool for the job.
True.
In a few scripts I use this sort of approach to logging...
set logFilePath to ((path to library folder from user domain) as text) &
"Logs:com.barryw.logFileName.log"
try
set logFile to open for access logFilePath with write permission
set eof logFile to 0 -- to overwrite the existing log
on error errmess
display dialog "an error ocurred:" & return & errmess buttons {"OK"}
default button 1 with icon stop
close access logFilePath
beep
return
end try
tell application "Console" to open logFilePath
set t1 to current date
write "+++++++++++++++++++++++++" & return to logFile
write "Backup Run started: " & t1 & return to logFile
write "+++++++++++++++++++++++++" & return to logFile
-- your script goes here
-- and wherever necessary insert a line like:
Write "text to appear in the log" & variableName & return to logFile
-- and continue with the script
-- until all ahs finished, then tidy up with
set t2 to current date
write "+++++++++++++++++++++++++" & return to logFile
write "Backup Run Finished: " & t2 & return to logFile
write "Time taken: " & t2-t1 & " seconds" & return to logFile
write "+++++++++++++++++++++++++" & return to logFile
close access logfile
Instead of cluttering up the console log (which gets used for other stuff as
well), this creates a dedicated log file in your library folder, which is
retained between runs and is not cluttered with other messages sent to the
console by the system.
The console app will keep the log open and update the display as the script
runs.
--
Barry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden