Latest Updates: os x

  • Quick command to check the status of a URL (Linux, BSD, OS X)

    22:54 on July 28, 2009 | 0 Comments Tweet This! | Digg This!
    Tags: , , os x,

    There may be times when you just want to do a quick check to see whether a web site is up, and/or what status message the web server is showing. This won’t actually show you if the page it served up is correct or not, purely the web server status code on whether or not it served something/anything/nothing!

    There are lots of status codes for web servers, and they are detailed here: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

    So, to be able to see the status message, and to check if a host is up or not, we can use the curl command.  curl is installed by default on OS X, but you may need to install it on your Linux distribution or BSD installation.

    So, to do a quick check from a command line:

    curl -Is http://droptips.com | head -n 1

    And you’ll get something back similar to:

    HTTP/1.1 200 OK

    Status code 200 is “OK”.

    HTTP/1.1 200 OK

    As another example, to show you how this will display different status codes, you’ll notice that if you visit: http://www.droptips.com you are redirected to http://droptips.com, purely because I prefer not to have www in the URL.  I do this by implementing a 301 (Permanently moved) from within Apache for any client going to http://www.droptips.com:

    $ curl -Is http://www.droptips.com | head -n 1
    HTTP/1.1 301 Moved Permanently

    As you can see, the web server returned a 301, and this is shown.

    curl can also take full URLs, so you can check whether or not a particular page/path is being served or not:

    curl -Is http://droptips.com/tag/tips/ | head -n1
    HTTP/1.1 200 OK

    So if you want to see if that new redirect is working, or just to see if your web server is up and serving requests, give curl a go!  This is just a basic overview of one thing you can do with curl - it’s a very flexible command, and can be used in a number of scenarios, some of which I will post about in the future.

     
  • Make your Mac Talk/Speak by using say (OS X)

    09:44 on July 28, 2009 | 0 Comments Tweet This! | Digg This!
    Tags: os x,

    This is a quick little tip, to turn text into speech on OS X.

    Open a Terminal and use the command say as follows:

    say droptips rocks

    Remember to have your speakers turned up and you’ll hear whatever you’ve typed after say.

    Interestingly, if you type:

    say x

    It’ll Say “exx” or similar.

    But if you do:

    say os x

    .. it’s clever enough to say “Oh Ess Ten” which is pretty impressive.

    What use is there for this?  Well.. you could use say in scripts to read out certain parts and to create alerts, I guess.  You could also SSH to a remote Mac, and get it saying things like “Bring me a coffee”, but your mileage may vary on whether this works or not (getting the coffee from whoever was in the room at the time, that is!)

    There are a few options, which are detailed within the manpage here: http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/say.1.html

     
  • Command Help using Manual Pages (man) (OS X, Linux, BSD)

    20:42 on July 27, 2009 | 0 Comments Tweet This! | Digg This!
    Tags: , , os x,

    As you start using the command line, you’ll come across thousands of different commands, all with their own options and ways of taking options.  Every command is different, but help is on hand in the form of man pages.

    Manual Pages (or man page for short) are the documentation distributed with every command (or, at least, should be with every command) which tells you how a particular command works.

    From a Terminal in OS X, Linux, or BSD, you should have access to a command called man.  man is the reader for these man pages, and parses them nicely onto the screen for you.

    So, for example, if you wanted help with the mount command, you would simply do:

    man mount

    … and you would be presented with the manual page for mount.

    This is true of any command, and there should always be a manpage with the command. It’s good practice to do this as a developer, but you may find cases where people don’t.

    There are also various web sites which have html versions of these manpages, and you can normally find these on the Linux or BSD distribution’s site you are using, or the Apple site.  For the sake of this post, the three below are for Ubuntu, FreeBSD, and OS X.

    Ubuntu - http://manpages.ubuntu.com/

    FreeBSD – http://www.freebsd.org/cgi/man.cgi

    OS X – http://developer.apple.com/documentation/Darwin/Reference/ManPages/

    So the next time you need help with a particular command, do a quick man thecommand and hopefully, you’ll have all the help you need!