Script help [login dialog]

Im trying to come up with a small script to run at login that displays an acceptable user policy to the user.

I have to policy saved in a .txt file

What i would like to know is how do i output the txt file into a script so the user can read it before excepting?

I dont want it just to open up text edit but to display the txt in a text box within the script screen


Do you mean that before the user logs in he must first click Accept and if he doesn’t, he can’t log in, or do you just want to post a message that must be dismissed as the first thing that happens?

I guess you were looking to something like this:

tell application "TextEdit"
	set CurrentDoc to (here the path to your text file) as alias
	open CurrentDoc
	set variableWithContentsOfTextdocument to every paragraph of the front document
	quit CurrentDoc
end tell

This opens your text document and puts all text in a variable

Model: iMac
Browser: Safari 312.6
Operating System: Mac OS X (10.3.9)

I want it to open as the first thing that appears, however i will need to disable everything else so they cant just ignore the policy and carry on working.

Here is what i have thanks to JanGeerling’s code;

tell application "TextEdit"
   set CurrentDoc to "text.txt"
   open CurrentDoc
   set variableWithContentsOfTextdocument to every paragraph of the front document
   quit CurrentDoc
end tell

display dialog CurrentDoc

however, because theres formating in the file (bold, hyperlinks, bulletpoints) apple script throws up an error.

any ideas?

This should really be some kind of FAQ or front page article, because it comes up often, and the answer is always:

You can’t really do this well enough to be worthwhile. You can make an AppleScript Studio app that throws up an EULA/terms and conditions/etc screen, but all you gotta do is force quit it or hide the app and go about your business. AppleScript isn’t really the right system for this, I’m afraid.

Edit: Also, it doesn’t sound like you want TextEdit. You want an AppleScript Studio app that displays a window with a large NSTextField view. Load the text file contents into that.

And having seen your explanation, I agree with Mikey-San. What you really want to do is alter the login screen itself and add to the login process and that’s not an AppleScript pursuit. I’m not sure it’s even doable.

You can hack the login window itself as shown in the link (and there are others) so your EULA appears at the head of the window and says: “By logging into this machine you are agreeing to blah blah…” but you won’t get advice here on how to do it.



Edit: See also:
Loginwindow Manager
Add a text message to the login window

I’ll testify that Mike Bombich’s LoginWindow Manager is good stuff - works as advertised.

What I meant in my previous comment, however, that simply reading /Library/Preferences/ into a script is not useful. The text does appear there if you’ve added text a la Mike B’s script, but you would never know where to put it if not.

What are you using if for, or why do you need a text file?

Seems like you can make something simple in Xcode, wich open a window when you start where the text is already embedded.
That’s when you want to make a ‘standard’ login window what say’s something like:

Or you can make a window on wich some contents you take out a text file

In this example you can take the hamburger from the text file.

I’m really good in workarounds :wink:

Jan Geerling