Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

trey5498

macrumors regular
Original poster
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?
 
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.
 
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.
 
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.
 
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.