Running terminal commands without logging in?

Discussion in 'macOS' started by trey5498, Jan 22, 2009.

  1. trey5498 macrumors regular

    Jun 16, 2008
    I know on windows allows you to run batch files without actually logging into the OS. This allows you to put an base image onto a PC and use batch files to change settings, place on active directory, and other things without having to log in.

    How do I do this with a mac? I want to be able to run 2 command line commands, one after the other once the other is finished, and then add it to Active directory. Would I do this in perl? and how do I get it to run without logging in so I can start it and then move on to other stuff?
  2. Consultant macrumors G5


    Jun 27, 2007
  3. trey5498 thread starter macrumors regular

    Jun 16, 2008
    I am trying to do this automatically because I am build each mac with an updated image. So I would pop in a CD, then select the build, it will install and then restart and run the background batch type files and connect to the active directory. This should happen without logging in.
  4. BlueRevolution macrumors 603


    Jul 26, 2004
    Montreal, QC
    What are you looking for? Something analogous to AUTOEXEC.BAT? What commands?
  5. linuxophile macrumors regular

    Nov 8, 2005
    Quite frankly I did not understand what you want to do with the batch.

    Anyway one possibility is to schedule the job using "at". This allows you to set a time for a job (could be a command or a sequence of commands or a bash file). It will start at that time whether or not you are logged in.

    Issue "man at" on the terminal and study it.

    Happy reading.
  6. trey5498 thread starter macrumors regular

    Jun 16, 2008
    is there a way to have a bash file to run without interference? As I said, have a the machine image dumped onto the machine, then upon reboot it will automatically run the file to retrieve settings from the server and to join active directory. I just want to be able to run 2 bash (or batch files for windows) without have anyone logging on and ONLY once.
  7. ppc750fx macrumors 65816

    Aug 20, 2008
    Right. I think I kinda grok what you want...

    I'd use a LaunchDaemon. You can either have it check for a flag (that's set after the first run) and exit if it's set, or have it unregister and delete itself after the first run -- it's really up to you which way you go.

    Apple's got all the dev. docs you need to write a LaunchDaemon on their site. launchd is a little weird, but it shouldn't be too hard if you take the time to read the documentation.

Share This Page