Tag Archive: unix

Lynx text-based web browser. It's not as complicated as it looks.

So you’ve installed Macports now and probably met your needs for the moment.  Did you ever wonder what else was available as a port?  Here is a short list of some other gems:

John the ripper – This is a password cracker.  It’s highly flexible.  Very handy for testing the strength of your own passwords or recovering a password in certain instances.  For instance, I’ve used it when administrating a web server when I have forgotten the password to a protected directory but I still have ssh or ftp access.  I’ll just grab the .htpasswd file and run it through John the Ripper and presto, it will give me one or more passwords.  It’s also good as a sysadmin if you want to make sure people are using good passwords.  You can run it against the password file, see which user’s passwords are returned and notify them that they need to set something stronger.  The port package is simply called john.

wget – Wget is one of my favorite handy little command line utilities.  All it does is downloads something from the internet and saves it.  This can be an html page or any file available on the web.  I use it when I want to download a tarball into a specific directory.  Instead of thumbing through directory trees on firefox, I’ll just copy and paste the URL into a shell and wget it.  Then it’s exactly where I need it and ready to be untarred.  The port package is called wget.

lynx – If you’ve never used Lynx before, now may not be the time to start.  Lynx is a command line, text-based web browser.  Before the days of Mosaic and Internet Explorer 1.0, Lynx was the browser of choice for early users of the web.  Some folks even snobbed the newer browsers reasoning that pictures just messed up the overage web experience.  Lynx is useful for when you are ssh’ing into your machine remotely and need to grab/install a file off the web or just do something similar quickly.  It supports cookies and many other modern features surprising enough.  The port package is called lynx.

There are TONS of other good packages out there.  Some other honorable mentions are bzip2, hexedit, hping3, nmap & tcpdump.  Feel free to post in the comments whatever cool packages you have found available as a Macport.

Almost every shell script written depends on something else.  Many times those things are already on your computer.  Basic stuff like cat and echo are arguably on every unix distribution in the known universe.  Other things start to vary more widely between different distributions.  Stuff like dialog or perhaps even perl may not be on your system.  Especially if it’s a compacted or embedded system.  To give your shell script a nice polished feel that makes it more portable and easier to use, you should add a couple of lines of code to check and make sure any extra items are there first.  Here is an example that checks for :

if ! which perl > /dev/null; then
echo “Please install perl or make sure it is in your path”

This will help people quickly determine why your script is failing to run on their platform.  Futhermore, it will save you support emails and save users of your script frustration.  Especially if they are newer users who aren’t accustom to debugging scripting glitches.

What is MacPorts?

Since getting my MacBook pro in early 2009 MacPorts has been one of the best and most useful tools I have discovered for it. MacPorts is a package management system similar to Debian’s apt-get. It allows you to install any of the 1000’s of packages that are available on other Unix platforms.  To use it, you’ll need Xcode which is Apple’s free integrated development environment.  Make sure you include both X11SDK and Unix Development when you grab the Xcode package.  Xcode is a huge package but it’s worth the space for ports and because it comes with Dashcode which is a nice little text editor that properly saves html, php, etc unlike text edit.

Once you have Xcode downloaded and installed, then grab the pre-built dmg file for your version of OS X from here.  One of the first commands you’ll want to make a note of is the update command.  That brings MacPorts itself up to date.  To run it you type:

sudo port -v selfupdate

More important is the package update command.  This one could take a while to run depending how many packages you have installed since it will download and recompile any outdated packages and dependencies you may have installed.  Be forwarded my computer took over an hour to upgrade.  To run it you type:

sudo port upgrade outdated

At the time of this blog post there are 6818 ports currently available.  You can see all of the ports right here.  The ports are categorized and searchable.  You can also search through all of the available ports right on the command line with these two commands:

ports list

ports search package

Once you find a package you want, installing it is a snap.  You just type:

sudo port install package

After you have installed a few ports, you can see a list of all ports and all dependencies that you currently have installed by typing:

port installed

Every time I look at the list I see new packages to install.  A few of my favorites are Perl, mysql, nmap & lynx.  You might laugh at Lynx but it really can be handy in a pinch.  Especially if you are SSH’ing into your Mac remotely.  Even if your package is not available, ports is really the best way to install dependencies for other packages that you may need to compile.  Things like gmake, autoconf & automake can be critical to running ./configure scripts and ports will make dependency hell a little less painful.

One final caveat is that when you upgrade to the next version of OS X, it will probably break some/most/all of your ports.  I haven’t had this experience yet but I’m guessing it won’t be much more painful than possibly upgrading Xcode, the MacPorts binary and running the upgrade command again.

Command line drum and bass

I was flipping through the latest winter 2009-2010 issue of 2600 magazine the other day on my way up to a family vacation and an article caught my eye. The author of the article, SigFLUP, had written a program to use your computer keyboard to manipulate a looping wav file. After installing SoX & libSDL I fired up the program with the test loop that was provided.  The author posted a demo of what kinds of variations could be made on one loop.

The program is packaged in the form of a one-size-fits-all shell script that has C embedded in it which compiles at run time. It took a little bit to start up in my Debian VM. I’d say 20-30 seconds.  Once it fired up, I was presented with a blank window that had spawned from the terminal.  That’s when you know it’s ready to run.

I’m not entirely clear to me how the program runs but from the article in 2600 it seems that it maps the 16-bits of the wav to QWERTYUI & ASDFGHJK with Q being the least significant bit and K being the most significant bit.  To use the program, you press two or more of these keys.  What the program does is replaces the values in all of the bits you are pressing with 1 if any of the bits you are pressing are set to 1.  In other words, if you press QWE and the values of QWE were 001, the values of those would then become 111.  All of the other values remain the same.  As you can imagine, this leads to sound crazy sounds.  Listen to the demo to see what I mean.  SigFLUP says in the article that the loop should be a multiple of 65535 samples in length but if you are just going for effects that you can export to your sound editor, that doesn’t matter too much.  Don’t miss the pitch bender keys which are “Z” & “X”.

The program understandably has a few glitches or I just don’t know how to use it right, but nevertheless it makes for a really cool proof of concept that I would love to expand upon someday.  You can download the program here from SigFLUP’s site.

Powered by WordPress. Theme: Motion by 85ideas.