Home Forums OS X Server and Client Discussion Questions and Answers Run bash scripts on login

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #368951
    ingenious7
    Participant

    Hi 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!

    #368953
    ingenious7
    Participant

    Thanks for the reply.

    I’ve run the script as root, and it looks like there may be an issue.

    #368954
    ingenious7
    Participant

    This 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?

    #368955
    ingenious7
    Participant

    I 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?!?
    😕

    #368967
    ingenious7
    Participant

    For 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.

    #368976
    ingenious7
    Participant

    I 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.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Comments are closed