Re: Login Applescript won't write to file
Re: Login Applescript won't write to file
- Subject: Re: Login Applescript won't write to file
- From: email@hidden
- Date: Fri, 29 Jun 2001 12:31:50 EDT
The other thing I noticed is that you reference cname before you define it.
Maybe this is the result of posting partial script code out of its full
context.
The other thing that can make a script silently fail is if it is enclosed in
a try block with no explicit "on error" handler. The script will give you no
indication it didn't do what you intended.
Jeff Baumann
email@hidden
www.linkedresources.com
In a message dated 6/28/01 2:04:25 PM, Timothy K. Wilkinson wrote:
>
I've got a very aggravating AppleScript problem I'd love some input on. We
>
have a sign in sheet in our computer labs to keep track of users. I wrote
>
an AppleScript that displays a dialog box. The user enters their id in the
>
box and the script writes that and the computer name, date and time to a
>
text file on our server. The script works perfectly when I run it from
>
Script Editor. When I run it using iDo Script Scheduler it runs fine and
>
even thinks it has written to the text file yet nothing shows up in it. Any
>
ideas why it would write to that file when run from Script Editor but not
>
when it runs alone?
>
>
>
--------------------Begin Script ----------------
>
>
set loginFile to "Data:log:lablogin.txt"
>
--set a flag to check if the email is a UVA ID
>
set idFlag to ""
>
repeat until idFlag is "true"
>
display dialog "Please enter your UVA Computing ID:" default answer
>
"" buttons "OK" default button "OK"
>
set userID to text returned of result as text
>
--checks to make sure the ID is valid
>
set idCount to (count of userID)
>
set the disallowed_characters to {"0", "1", "2", "3", "4", "5", "6",
>
"7", "8", "9"}
>
if character 1 of userID is in the disallowed_characters or
>
character 2 of userID is in the disallowed_characters or ,
>
character idCount of userID is in the disallowed_characters or
>
idCount > 6 or userID = "" or idCount < 2 or (userID = cname) then
>
display dialog "Please enter a UVA Computing ID" & return &
>
"Example: abc2d" buttons "OK" default button "OK"
>
set idFlag to "false"
>
else
>
set idFlag to "true"
>
end if
>
end repeat
>
set cname to (computer name) as text
>
--this call uses the OSAX "date string for"
>
set cDate to date string for (current date) in short format
>
set the cTime to my format_time_using(the current date, ":", {"HH",
>
"MM", "SS"})
>
set login_time to (cDate & space & cTime) as text
>
--writes all the information to loginData
>
set loginData to ("login" & " " & userID & " " & cname & " " &
>
cname & " " & login_time & (ASCII character 13) & (ASCII character 10))
>
as text
>
--writes the information to a text file as tab-delimited
>
write loginData to file loginFile starting at eof
>
end tell
>
>
------------------End Script------------
>
>
>
>
TIA,
>
>
Tim Wilkinson
>
ITC-ACHS
>
University of Virginia
>
email@hidden
>
email@hidden