Problem upgrading from Ubuntu 10.10 to 11.04 on Mac Pro no bootable device found

Posted by | Posted in Command-Line, OS X, Ubuntu | Posted on 14-11-2011

Recently, I had an issue upgrading my Mac Pro from Ubuntu 10.10 to 11.04. After the install and the initial reboot I received a “No Bootable device found”. This isn’t the first time that this has happened to me during a Mac Pro Ubuntu upgrade. Many tech boards had offered the reset your PRAM or reset your Open Firmware as the solution to re-detecting the ubuntu partition. All had failed. Resetting your PRAM and your Open firmware won’t tell the system that “X” partition is bootable. Ultimately it came down to re-blessing the ubuntu partition with in OS X.

I used a Mac OS X startup disk to gain access to a terminal session to run the bless command.

/usr/sbin/bless --device /dev/disk2s1 --setBoot --legacy

Creating a SSH Tunnel

Posted by | Posted in Command-Line, Guides, Linux, OS X, Server, SSH, Tunneling, Ubuntu | Posted on 01-02-2011

To traverse firewalls that block incoming SSH connections or to access a computer with a non routable IP address, you can create an SSH tunnel. When creating a SSH tunnel, you’ll generate the tunnel on the host system and connect it to another system.

With the SSH command, you’ll use the “-R” flag, that allows reversible communications or a reverse tunnel.

This command that I normally use:

It states, create a reversible SSH tunnel from this localhost port 22 to USER@SERVER on port 10000.

/usr/bin/ssh -R 10000:localhost:22 USER@SERVER

You’ll need to leave this connection open otherwise the tunnel will collapse. Normally I execute a program at the other end to keep the connection alive. Some SSHd configurations will drop connections due to inactivity.

To connect to the tunnel from USER@SERVER:

use ssh to connect to your USER account on the host server via port 10000.

/usr/bin/ssh USER@localhost -p 10000

this will give you the login prompt at the host server. User your login information or you can also setup SSH Keys.

How to get rid of cron warnings

Posted by | Posted in Bash, Code, Command-Line, Cron, Linux, OS X, Server, Ubuntu | Posted on 31-01-2011

If a cron job executes with unmanaged warnings for data, you’ll generate LOTS of emails to your account. Here is an easy way to redirect all that extraneous data.

Just add “>> /dev/null 2>$1″ to the end of each of your cron jobs.

0,10,20,30,40,50 * * * * /path/to/script >> /dev/null 2>&1

PHP and $argv

Posted by | Posted in Code, Command-Line, Functions, Guides, Linux, OS X, PHP, Server, Ubuntu | Posted on 31-01-2011

I’ve been adding $argv functionality to all of my PHP maintenance scripts. I am doing this, so I don’t have to edit a variable each time I want to execute it.

A PHP $argv example.

< ? PHP
#	test.php
#	demonstration of $argv
#	Dan McCoy
#	January 31 2011
$command = $argv[1];
$GLOBALS['script'] = basename($argv[0]);
$GLOBALS['ver'] = "1.0";
$GLOBALS['file'] = $argv[2];
function help() {
	echo "Help for ". $GLOBALS['script'] ."\n";
	echo "-h \t Help prompt \n";
	echo "-v \t Version ". $GLOBALS['ver'] ."\n";
	echo "-g \t Grab file from X \n";
	echo "-f \t Reformat data from X \n";
	echo "-l \t Load data from X \n";
}// end help
function grab(){
	@exec('/opt/local/bin/wget -O '. $GLOBALS['file'],$retval);
	return "Grab completed ". $retval[0] ." \n";
}// end grab
function reformat() {
	$fp = $GLOBALS['file'];
	$file = fopen($fp,'r');
	$data = fread($file,filesize($fp));
	$data = str_replace("<br /><br />","\n\n",$data);
	$data = str_replace("<br />","\n",$data);
	$data = strip_tags($data);
	$data = str_replace("\t","",$data);
	$fp = $GLOBALS['file'];
	$file = fopen($fp,'w');
	return "Reformating completed \n";
}// end reformat
function load() {
        $fp = $GLOBALS['file'];
        $file = fopen($fp,'r');
        $data = fread($file,filesize($fp));
	return $data;
function delete() {
	$ret = @unlink($GLOBALS['file']);
	if ($ret==TRUE){
		return "File has been deleted \n";
		return "There was an ERROR deleting ". $GLOBALS['file']."\n";        
}// end delete
function switch_default() {
	echo "Command not found \n";
switch($command) {
	case "-h":
	        echo help();
	case "-g":
        	echo grab();
	case "-f":
		echo reformat();
	case "-l":
		echo load();
	case "-d":
		echo delete();
}// end switch
? >

Executing more then 1 command at once

Posted by | Posted in Bash, Code, Command-Line, Cron, Linux, OS X, Server, Ubuntu | Posted on 30-01-2011

Many times, I have to execute sequential commands inorder to complete a task. Below is an example of how to do this.

/path/to/command argv1 && /path/to/command argv2

I normally use this sequential order when pulling raw data from a source and then reformatting it for my needs.

15 * * * * /usr/local/bin/pullsource grab && /usr/local/bin/pullsource reformat

Change the default crontab editor – Bash

Posted by | Posted in Bash, Code, Command-Line, Cron, Guides, Linux, OS X | Posted on 30-01-2011

You can change your default crontab (crontab -e) by setting the EDITOR environment variable in BASH:

hostname# which vi
hostname# export EDITOR=/usr/bin/vi
hostname# set | grep EDITOR

Applescript – folder and file counter

Posted by | Posted in Applescript, Code, OS X | Posted on 16-09-2010

set theFolder to (choose folder)
set thePath to POSIX path of theFolder
set fileCount to 0
set folderCount to 0
tell application "Finder"
	set theFileList to every item in folder theFolder
	repeat with x in theFileList
		if not character 1 of ((name of x) as string) is equal to "." then
			if kind of x is equal to "Folder" then -- "folder" depends fromĀ  the finder language 
				set folderCount to folderCount + 1
				set fileCount to fileCount + 1
			end if
		end if
	end repeat
end tell
display dialog "There are " & folderCount & " folders andĀ  " & fileCount & " files in " & thePath

Applescript – Change folder color based on size

Posted by | Posted in Applescript, Code, OS X | Posted on 16-09-2010

property theFile : missing value
property theFolder : "test"
property thePosixPath : "/Users/user/Desktop/"
property theAliasPath : "Users:USER:Desktop:"
property theSize : missing value
tell application "Finder"
	set theSize to do shell script "du -s -k " & thePosixPath & theFolder & " |awk '{print $1}'"
	if theSize > 700000 then
		set label index of (folder theAliasPath & theFolder) to 2
	end if
end tell

Randomly Choose A Buddies’ Status Message As Your Own – OS X – Applescript

Posted by | Posted in Applescript, Code, OS X | Posted on 10-11-2009

tell application "iChat"
tell application "iChat" to set messagelist to get status message of every buddy
where status is not offline
set msglistcount to count messagelist
set theMessageList to {}
repeat with x from 1 to msglistcount
if item x of messagelist is not "" then
copy item x of messagelist to end of theMessageList
end if
msglistcount = msglistcount - 1
end repeat
set newStatus to some item of theMessageList
set status message to "i'm in your internets stealing your status messages : " & newStatus
end tell

How to download files via command line – OS X, Ubuntu : Wget, cURL

Posted by | Posted in Command-Line, Linux, OS X, Ubuntu | Posted on 21-07-2009

For most server administrators doing system updates or installing patches via a command shell is normal, but for the average user trying to patch his new system, this task might be a little difficult. Opening a terminal and downloading a file, just by typing in a few words, is not as simple as clicking a download icon on a website, tho, once you learn how to use Wget or cURL, it will be.

From my understanding, Wget is a stand-alone application, that is command-line only. And, cURL is a cross-platfrom API library called libcurl. Personally, I like Wget better then cURL, but that’s just because I am bias.

If you want to know all the nitty-gritty differences, check out curl vs Wget.

Wget – The non-interactive network downloader. (I refer to it as, WWW Get or Web Get).

wget [option]… [URL]…

curl – transfer a URL

curl [options] [URL...]

How to download a file with wget:


How to download a file with cURL:

curl -O
curl >

Join the mailing list

Check your email and confirm the subscription