Home › Forums › OS X Server and Client Discussion › Questions and Answers › Run bash scripts on login
- This topic has 7 replies, 2 voices, and was last updated 17 years, 11 months ago by
ingenious7.
-
AuthorPosts
-
May 7, 2007 at 2:37 am #368951
ingenious7
ParticipantHi All,
I have written a script to help identify some physical security issues we are having in one of the labs at the school campus. It is a bash script that takes a photo of the use on login using the built in iSight camera.
I have tried to get this to run on login using the following
[code]sudo defaults write com.apple.loginwindow LoginHook /path/to/script[/code]
This doesn’t work. I am wondering if LoginHooks can only run AppleScripts or I can get my bash script to run.
Help greatly appreciated!
May 7, 2007 at 3:26 am #368953ingenious7
ParticipantThanks for the reply.
I’ve run the script as root, and it looks like there may be an issue.
May 7, 2007 at 4:02 am #368954ingenious7
ParticipantThis is the script I am running, and I am using an additional compiled script from [url]http://www.intergalactic.de/hacks.html[/url] called isightcapture.
[code]#/bin/bash
CallFile=/$(users)-$(date +%Y-%m-%d-%X).jpg#echo $CallFile
/usr/local/bin/isightcapture $CallFile[/code]
Is there something wrong with the way I am coding this. I have even tried getting the script to do a mkdir to check it is running at login and nothing.
I have attempted to create a Login script using Mike Bombich’s LoginWindow Manager. Is there something I am missing?
May 7, 2007 at 4:44 am #368955ingenious7
ParticipantI found this in the System.log. It seems login scripts are crashing.
[code]May 7 11:57:39 imac-computer /System/Library/CoreServices/mcxd.app/Contents/Resources/MCXLoginLogoutScriptTool: login: “loginscripts” in “com.apple.mcxloginscripts” is not a CFArray.
May 7 11:57:39 imac-computer /System/Library/CoreServices/mcxd.app/Contents/Resources/MCXLoginLogoutScriptTool: login: /Volumes/Macintosh HD/CaptureUser returned 5; exiting.
May 7 11:57:39 imac-computer crashdump[165]: MCXLoginLogoutScriptTool crashed[/code]What is a CFArray? Why would the MCXLoginLogoutScriptTool be crashing.
Surely somebody easily runs login scripts on OS X 10.4.9?!?
😕May 7, 2007 at 11:58 pm #368967ingenious7
ParticipantFor anyone interested, I found the solution –
[code]sudo -s
echo ‘#!/bin/sh’ > /Library/Management/login.sh
echo ‘echo $1: `date` >> /tmp/login.log’ >> /Library/Management/login.sh
chmod a+x /Library/Management/login.sh
defaults write /var/root/Library/Preferences/com.apple.loginwindow LoginHook /Library/Management/login.sh[/code]This is like a test. To make sure it is working, log in as a user, and enter
[code]cat /tmp/login.log[/code]
My script works perfectly now. I can have login photos taken via iSight camera, and sent straight back to my desk. A little Big Brotherish I think. Oh well.
May 8, 2007 at 3:00 am #368976ingenious7
ParticipantI was sure I added it the same way. The only difference was that I renamed the script to login.sh. I don’t know if this made a difference or not.
-
AuthorPosts
- You must be logged in to reply to this topic.
Comments are closed