Follow us on...
Follow us on Twitter Follow us on Facebook
Register
Page 1 of 2 12 LastLast
Results 1 to 8 of 14
  1. #1
    Zeus is offline Registered User
    Join Date
    May 2001
    Location
    Italy
    Posts
    243
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to launch a script on startup?

    I need to launch a script on startup after autodiskmount execution.
    (the /etc/rc file has been already processed i suppose)
    What to do ???

    Is there a file to edit ??
    Zeus
    (filippo_zeus <at> tin <dot> it)
    ----------------
    iBook G4 1000, 768 Ram, 40 Gb
    (OSx 10.3.9 and OSx 10.4.2)

  2. #2
    Zeus is offline Registered User
    Join Date
    May 2001
    Location
    Italy
    Posts
    243
    Thanks
    0
    Thanked 0 Times in 0 Posts
    in Italy we say: gagliardo!!!
    it sounds like: Very very very cool!!!

    Thanks ...
    eventually i'll post some help request here!!
    Zeus
    (filippo_zeus <at> tin <dot> it)
    ----------------
    iBook G4 1000, 768 Ram, 40 Gb
    (OSx 10.3.9 and OSx 10.4.2)

  3. #3
    jcihocki is offline Registered User
    Join Date
    Feb 2002
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    WARNING about StartupItems

    MAKE SURE your script backgrounds whatever it starts up. OSX is not very smart in regards to things like this yet, and it WILL NOT fork things it starts up automatically... and I've got news for you, this is a very painful thing to forget. If you put a script in StartupItems that doesn't background, Mac OSX startup will sit and wait for it to return. This means you can't go and change your startup disk to os9, and because when you start up command-s, you get a read only file system (real useful, eh?) So your only option is to start up from an OS 9 cd. (Good luck finding it, if you're like me). I searched around for a way to disable startup items on startup, but couldn't find one, and i'm not sure if one exists.

    That being said, have fun and be careful.
    -John

  4. #4
    blb
    blb is offline `'
    Join Date
    Apr 2001
    Location
    CO, USA
    Posts
    651
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Note that you can remount your disk in single-user to make it writable; simply run /sbin/mount -uw / to do this (it should also print this out when you boot single-user).

  5. #5
    Aqualung is offline Banned
    Join Date
    Nov 2001
    Location
    Ann Arbor
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts
    As an alternative to the startup items, you could open the login preference panel and add the script to login items startup list. That way it runs whenever you log in.

  6. #6
    Zeus is offline Registered User
    Join Date
    May 2001
    Location
    Italy
    Posts
    243
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Some questions about scripting ...

    Excuse me if I'm annoying you ... it's because i'm new to Unix!

    I've some questions for who want to help me ...

    1)
    why i must add in the top of the script this line: #!/bin/sh?
    Isn't /bin/sh the sh shell paht ?? and if this line has the # symbol isn't this mean the command will not be executed ??
    ------------

    2)
    what about the 2nd line ?? . /etc/rc.common?? i've noticed this is used in the /etc/rc file too ! What's this command for ??
    ------------

    3)
    in the script is it possible to define a variable containing anothe variable?

    Example:
    variableone= /Volumes/MacOS9
    variabletwo=${variabletwo}/System Folder
    -----------

    4)
    how to tell the script that 'if a directory not exits' do 'create a directory' then (meaning the directory exist) 'continue script execution'
    -----------

    5)
    how to tell the script that 'if a file exist' do 'remove the the file' then (meaning the file not exist) 'continue script execution'
    -------------

    ... about the .plist file ...
    6)
    who can help me to understand and correctly configure the plist file ??
    what these values means ??

    (NOTE: The values below are taken from the testuser link in this tread)
    {
    Description = "IPAliasing";
    Provides = ("Secondary IP Addresses");
    Requires = ("Resolver");
    Uses = ("Network Time");
    OrderPreference = "None";
    Messages =
    {
    start = "Starting IP aliasing";
    stop = "Stopping IP aliasing";
    };
    }


    i hope i was sufficently explicit ... thanks a million to everyone can help me !!
    Zeus
    (filippo_zeus <at> tin <dot> it)
    ----------------
    iBook G4 1000, 768 Ram, 40 Gb
    (OSx 10.3.9 and OSx 10.4.2)

  7. #7
    blb
    blb is offline `'
    Join Date
    Apr 2001
    Location
    CO, USA
    Posts
    651
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: These multi-part questions are too much like the SATs

    Originally posted by testuser
    ...
    2) Not sure, but I suppose it means that you can use variables defined in those shell scripts
    ...
    Your supposition is correct; it is basically like an include, variables become available to the current script, any commands in that referenced script are run, etc.

    ...
    4) There is no way to check existence of a file or directory in Bourne shell, but you can check size, or if it is a file or directory. (If you use Korn or Bourne again shells, you can use -e in the test).
    ...
    You can do this in Bourne, use test, which should also be the program known as [ (try a whereis [ sometime).
    This should work in Bourne on any OS:
    Code:
    test ! -d tempdir && mkdir tempdir
    to create the directory if it doesn't exist. See man test.

  8. #8
    Zeus is offline Registered User
    Join Date
    May 2001
    Location
    Italy
    Posts
    243
    Thanks
    0
    Thanked 0 Times in 0 Posts
    At first i wanna thanks all people (a particular thanks goes to testuser) who posted and helped me to develop my little script.
    Unfortunatly for you [ :-))) ] now i have another question...
    i've set my script so that if a defined directory is not find the script stop itself and exit.
    Now is it possible that when (and if ) this appen to see a message in the mac os x boot box ??

    thanks
    Zeus
    (filippo_zeus <at> tin <dot> it)
    ----------------
    iBook G4 1000, 768 Ram, 40 Gb
    (OSx 10.3.9 and OSx 10.4.2)

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. How to run a script at startup?
    By rformiga in forum Unix & X11
    Replies: 3
    Last Post: May 8th, 2003, 09:30 AM
  2. How does one launch an ".app" from a shell script?
    By jgc94131 in forum Unix & X11
    Replies: 5
    Last Post: January 11th, 2003, 02:20 PM
  3. Help setting a program to launch at startup with root permissions...
    By Jason in forum Mac OS X System & Mac Software
    Replies: 6
    Last Post: September 12th, 2002, 01:44 PM
  4. startup script for terminal
    By neo36 in forum Unix & X11
    Replies: 0
    Last Post: July 5th, 2002, 06:48 PM
  5. HOW TO STOP SPAM -- join the fight!
    By GadgetLover in forum Apple News, Rumors & Discussion
    Replies: 11
    Last Post: April 11th, 2002, 02:52 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •