Looking for help!
I am in charge of writing an applescript for my job. I am JUST starting to learn applescript.
Can anyone help me?
I need to write an AppleScript that once the computer starts up it
opens to a a User login screen.
Also allow my students on a Macintosh to login and connect to a Novell Server using Native File Access.
The script that I need (I think) is
Tell Finder to open chooser
Tell chooser to open appleshare
Tell appleshare to enter and open server IP address (172…)
connect
launch login screen
(User types in name)
Connect to Server
Mount server
log out to desktop and reopen a new user login screen without shutting down computer.
Needless to say being a newbie I am a bit lost.
If I can figure this out the school will keep the macintosh’s.
Any help greatly appreciated.
Here are two separate scripts, one for login, one for logout. Based on your post I assumed you wanted a script that you’d put in the startup folder and prompt the user for a password to log into a volume via IP. The second script checks to see if that volume is mounted and if it is - put’s it away. Tested successfully on Mac 9.2 Applescript V 1.6
Log In–save as an application and put in startup folder, or if users need to run put in AppleMenu or something
--=============================================================================
--If the users can run the log in script at any time manually...
-- check to see if volume is already mounted
set VolumeName to "Volume Name" as string
set DiskList to list disks --get all disks currently mounted --unimportant if this is strictly a script that is run on startup
if DiskList contains VolumeName then --
tell application "Finder"
activate --bring the Finder to the front so the dialog isn't hidden
display dialog VolumeName & " is already mounted" buttons {"Okay"} default button 1 with icon stop
return
end tell
else
login() of me --invoke the login subroutine
end if
--=============================================================================
--if this is strictly a startup script delete everything prior to this and enable the next line
--login() of me --invoke the login subroutine
--log in subroutine
on login()
--to prompt a user for a password
--set ValidPassword to "macuser" --this is the password it has to match
--or set up a group of users
set ValidPassword to {"Rob", "JJ", "David", "HAS", "Ray", "TJ"}
tell application "Finder"
activate --bring the Finder to the front so the dialog isn't hidden
set Dialogin to display dialog "Please enter your password" default answer "" with icon stop
set UserEntry to the text returned of Dialogin
set ButtonReturned to the button returned of Dialogin
end tell
--check to see if the user cancelled
if ButtonReturned = "Cancel" then --the user cancelled
return --end the script
end if
if ValidPassword contains UserEntry then --if your password, or list of passwords/users contains what the user entered - log in
try
--this is how you mount a volume via IP
mount volume "afp://server.IP.address/Volume Name" as user name "username" with password "password"
on error number errmsg --if some error occurs let the user know
tell application "Finder"
display dialog "A login error occurred." & return & "Error: " & errmsg buttons {"Okay"} default button 1 with icon note
end tell
end try
else
tell application "Finder"
display dialog UserEntry & " is not a valid password." buttons {"Cancel", "Try Again"} default button 2 with icon note
end tell
if the button returned of the result = "Try Again" then
--run the script again
login() of me
end if
end if
end login
Log Out
--to log out, specify the volume name you want to put away
set VolumeName to "Volume Name:" as string--be sure to end with ":"
try
set alsVolumeName to VolumeName as alias --see if it is mounted before trying to put away
tell application "Finder"
try
put away alsVolumeName
on error
display dialog "There was a problem trying to put " & VolumeName & " away." buttons {"Bummer"} default button 1 with icon note
end try
end tell
on error --if it isn't there
tell application "Finder"
activate
display dialog "The Volume " & VolumeName & " was not mounted." buttons {"Okay"} default button 1 with icon note
end tell
end try
The Log in script is not meant to be strong security by any stretch of the imagination. It can be easily cracked - but for a simple user log in - it works.
*If you run the log-out script in a script editor it will most likely ask you to log into the remote server when it finishes. It will not do this if it is saved as an application.