Tag Archives: scripting

BASH Scripting – How To Create Executable Script

There are many ways to achieve this – but I find this to be the fastest way as it is all done through command line.

Creating The Script File

Open Terminal.app from /Applications/Utilities/Terminal.app

In the Terminal window that opens, we are going to create a directory called scripts on our desktop and then create a shell script file within that directory – use the following command:

//"mkdir" creates a directory on your desktop - no different than right clicking on desktop
mkdir /Users/yourusername/Desktop/scripts

//"touch" just creates an empty file with a name and extension you specify
touch /Users/yourusername/Desktop/scripts/kickstartscript.sh

We also need to make the script executable.

//chmod is used to set permissions - in this case, executable permissions
chmod +x /Users/yourusername/Desktop/scripts/kickstartscript.sh

You now have an executable file. You can use any text editor (may I suggest TextWranger – just do a google search for it) to open the file made in the scripts directory on your desktop. You may also use VIM or other command line text editor as well, but chances are if you are reading this – you would be better suited to start with a program based text editor like TextWrangler.

Once you have the file open – all you have to do is add


to the top of your file and you are ready to start scripting.

The line above just tells Terminal that it is a bash file with bash commands.

Thanks for reading!

Blessing A Mac Hard Drive

Blessing Mac Hard Drive

In the world of IT, you never know what you are going to come up against. I have seen some of the strangest stuff imaginable pop up over time, Apple and PC alike. The one thing they all have in common – an end user who can provide no details to the events leading up to the event. With that being said, here is the first of hopefully many installments of my experiences and how I fixed the impossible. Okay, definitely not impossible – just checking if you are paying attention. On we go…

Don’t care about the long story? Skip it and see the direct details!

Today I encountered two iBooks that hung on the network imaging process. Naturally, my impatience got the best of me and I decided to restart them after some time of not finishing. As it turns out, the image process completed successfully – minus being able to boot.

On first startup:

I got the dreaded folder screen, but it never showed the question mark that I have grown accustomed to seeing.

I restart holding the option key just after the Apple “Chime” noise:

This allowed me to select the drive and actually boot up the computer. It was working! Kind of…

Now, I restart the computer and it boots right back to the same folder screen with no question mark. So the only way it will boot is by holding the option key at startup and selecting the boot volume.

I decide to try to set the startup disk by going to System Preferences -> Startup Disk and the drive doesn’t show up to select. Somehow, I am booted to a drive that Startup Disk doesn’t even recognize.

Boot to CD and startup disk gives me the same thing…


1.) iBook will not boot on its own– only get Apple folder with face
2.) Can boot when hold option key and select the boot volume
3.) Hard drive does not show up in “System Preferences… -> Startup Disk” to set as the boot drive
4.) Drive show in disk utility – and verifies successfully

The Fix:

bless --folder /Volumes/YOURHARDDRIVENAME/System/Library/CoreServices --bootinfo –bootefi

I issued this command to bless (make it bootable) the system and had it rebuild the boot files needed.

Next I set the boot drive with the following command.

bless --mount /Volumes/YOURHARDDIVENAME –setBoot

NOTE: If your hard drive name has a space in it – you need to escape the space with a backslash. If your hard drive name is “Macintosh HD” the command would be the following.

bless --mount /Volumes/Macintosh\ HD –setBoot

Voila – iBook was completely fixed!


Take this experience with caution – and if you are not sure if it applies to your situation – do not attempt it. I take no responsibilities for your problems – I do that enough in my day job!