Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Background

My job gives me temporary MacBook Pros for travel purposes. I get them with a fresh OS install before I leave, and when I return, they blank the hard drive. The trips usually require some sort of development work, which means I'd prefer to install my entire development stack on the machine, but doing so every time would be tedious and a waste of time. I'd like to write a script that does all of the installation for me.

Question

The big issue I've run into is having to download the Xcode command line tools. For the time being, I can stash the DMG in my Dropbox or some sort of privately accessible cloud storage. I was wondering, however: is there a way to download these tools from Apple in a scriptable fashion? The main obstacle seems to be logging into Apple's Developer site. If I could download the DMG from Apple in a way that only required me to type in my ID and password from the command line, that would be great (or even better, download it without a password).

From searching around, it seems like there may exist URLs for the command line tools that may allow me to download them from the command line. (see, for instance: http://stackoverflow.com/questions/9329243/xcode-4-4-command-line-tools)

share|improve this question
1  
Do you have XCode on the machine, but not the command line developer tools? I know if XCode is installed you can do xcodebuild -license; xcode-select --install to do an unattended install of the command line developer tools. –  Ian C. Dec 22 '13 at 22:45
    
Not usually. Typically, I'm given a machine with a fresh, vanilla install of OS X for security reasons. This situation could apply to migrating a setup to a new machine also, which is another reason I'm interested. After digging around the source code of the Developer Tools web site, I was able to find a URL I could use to download XCode via curl. That said, I'm not sure Apple wants the actual URL publicized, and they seem to go to considerable lengths to obfuscate the URL. –  Geoff Oxberry Dec 24 '13 at 5:10
add comment

1 Answer

Install wget and if you are running osx 10.8.5 usable keychain scripting for lion:

http://www.red-sweater.com/blog/2035/usable-keychain-scripting-for-lion

Pass your developer username and password to wget via "usable keychain scripting".

share|improve this answer
    
As you note, wget isn't installed by default, which makes it undesirable for bootstrapping a development setup. You can do something similar with curl with the -u option, which is installed by default (albeit an old version). I'd like to put the XCode download into a script under version control, so including even a user name is something I'd rather avoid, but I may have to live with. –  Geoff Oxberry Dec 24 '13 at 5:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.