The new location options in networksetup are pretty interesting and while I’ve mentioned them in writings in the past I thought I would explore scripting against them, as they do reflect an interesting new challenge, mostly if you’re looking to script against non-booted volumes. To script against a booted volume is fairly straight forward. You have the -listlocations, -getcurrentlocation, -createlocation, -deletelocation and -switchlocation options which lists all locations, lists the current location, creates a location, deletes a location and potentially switches a location. To get started, first look at what locations your system has: networksetup -listlocations If you are on a freshly installed system you should see Automatic as your…
-
-
php from the Command Line
Using php at the command line isn’t an exact science in regard to which scripts that run in a web page will function from the shell. However, if you are automating many tasks, such as how you would go about with a shell script, then php is a nice alternative to other languages. To get started, let’s look at the version of php that we’re running. A quick way to test this is type the following from the command line. php -v This should result in something like the following message, which includes the version of PHP you are running and the current date: PHP 5.3.0 (cli) (built: Jul 19 2009…
-
Adding Color to & Customizing the Shell Prompt
As promised in the article on colorizing the terminal, let’s look at how to customize your bash prompt. First note that text as well as the following can be used in your string. a – ASCII bell d – date e – ASCII escape h – LocalHostName H – HostName j – number of jobs managed by shell l – basename of terminal device name n – insert a newline r – insert a carriage return @ – time in 12-hour HH:MM format A – time in 24-hour HH:MM format t – time in 12-hour HH:MM:SS format T – time in 24-hour HH:MM:SS format u – current user v –…
-
10 Quick SysAdmin Time Savers
I’m not gonna’ lie to you, I’m a pretty lazy admin. As such, I look for ways to reduce the amount of typing I have to do routinely. And ways to not make mistakes that I made when I was young and needed the rupies. The more time I spend at the command line, the more I use these, so here goes (hope they help you in some way shape or form): Make your own bin and put stuff you use often in there. You can use any folder you like and just include it in the export PATH=$PATH line by throwing a : at the end and typing that path.…
-
Mac OS X: Require Password at Single User Mode
By default, Mac OS X will simply give you a shell when you perform a Single User Mode startup. However, you can force OS X to ask for a password in order to gain shell access. To do so, vi the /etc/ttys and change secure to insecure. Once you have done so, create a password in /etc/master.passwd for root.