Login shell scripts - if/where/how?

Discussion in 'Mac Programming' started by tom., Jan 13, 2009.

  1. tom. macrumors 6502

    tom.

    Joined:
    Nov 9, 2007
    Location:
    UK
    #1
    Hi all,
    I have been polishing up on some basics of shell scripting, I decided a nice task would be to create a dynamic MOTD (RAID disk stats etc) since im using SSH so much at the moment.

    The MOTD generation script works great when run manually and I am aware I could just set up a cron job - but I feel this is a bit of a bodge.

    My idea is to run the script before the MOTD is called, somewhere slightly before the shell is run

    See:
    http://developer.apple.com/documentation/Darwin/Reference/ManPages/man5/motd.5.html

    After login, before shell is run - Where is this? Can I get to it?

    At the end of my teather looking around for an answer on BSD/*nix/OS X forums and google searches! I have tried putting the script call in /etc/profile but this seems to be run after the shell is run and hence the motd has already been called, so updating it is too late to reap the rewards.

    Any help appreciated!!

    This was supposed to be a bit of fun but I have to finish it for the sake of elegance and completeness!
     
  2. tom. thread starter macrumors 6502

    tom.

    Joined:
    Nov 9, 2007
    Location:
    UK
    #2
    Problem solved - sort of

    It seems the motd is called from the login binary which I didnt realise. This means you can't call an update motd script before the motd is displayed, unless you updated it before a login (would you really want to do that?).

    Instead i am using ~./bash_profile to call a script which outputs the stats i want and ignoring the motd functionality completely.

    Hope that is useful to someone, sometime.
     

Share This Page