Archive for the 'Mac OS X general' Category

unix toolbox

Friday, August 18th, 2006

Mac OS X comes with so many tools now, that there are myriad ways of getting things done. I had to present a list of files in a directory with the modification dates recently. I came up with this one liner:

ls -lT | awk ‘{print $10, $7, $8, $9}’ | bbedit

if you do a ls […]

Doing the Perl curl

Thursday, July 27th, 2006

A while back I wrote a post about a ftp shell script. A number of people told me I should use curl instead. Here is one I wrote using both perl and curl to move some files from a site. I start with a list of file names. They don’t have the .pdf extension in […]

Sorting file names with Perl

Monday, July 24th, 2006

I had to sort directories of pdf files that had identical names except for the last characters before the extension.pdf. Perl has a nice built in sort routine, but when I used it to sort like this:
@sortedlist = sort @listOfFiles;
I would end up with filenames in sort order for the most part except 10 would […]

Javascript from the command line

Thursday, April 13th, 2006

Javascript has come a long ways. The Mozilla project has released a couple of tools for javascript writers. I recently added the capability to my Mac of being able to write javascript then run and debug it from the command line, just like I would a perl script. Rhino is a java tool that will […]

Using Perl to change file names

Wednesday, March 29th, 2006

I run into the situation of having to rename so often that I am constantly tweaking my solution. Here I had to remove some extraneous characters on file names that a client had added. All we wanted where the first characters that started with DSFC and then the 4 digits. I had to drop off […]

Trusty Applications

Saturday, March 11th, 2006

I have several handy applications that I use on my mac daily. Obviously a mail app and browser. Safari is very nice. I’m using Apple Mail, but Thunderbird is really a nice mail app, too. But for me, much of the business of computing is storing information, and being able to get to that information […]

Applescript and shell move files script

Tuesday, January 24th, 2006

Do you ever need to move a bunch of files to a specific location? Or do you want to backup certain files and need a nice method for moving them to a second drive or location? This following script can be helpful. You can re-write it for your particular purpose. I originally wrote it to […]

Restart Mac Classic from a script

Monday, January 23rd, 2006

I’ve been asked this a couple of times, so I’m revisiting this topic (see post 50). I didn’t think it would have been too common for people to want to restart classic from a script, but apparently there are some. If this doesn’t interest you, at least you might want to take a peek at […]

Tiger and Unix scripting

Sunday, July 10th, 2005

It has been quite some time since I have had a chance to write. I finally made the switch to Tiger. It was a long process for me. I installed a DVD drive into my blue and white G3 to make Tiger installation easier. While I was upgrading my machine I decided to soup it […]

Wordpress 1.5 themes, virtual hosts

Friday, February 25th, 2005

Since I upgraded to WordPress 1.5, being a web designer, I had to give themes a try. Kubrick is a beautiful interface, but I desired to build my own interface. I have called this one soothe, since it is aqua inspired.
It took me a little while to figure out what files controlled what behaviour. It […]

Using you mac to share an appletalk printer

Tuesday, January 25th, 2005

This is a little easy trick for those in a Windows network environment. If you have a laserwriter that your pc can’t see (such as an appletalk protocol printer) and you have an OS X box that sees it, you can turn on Windows sharing in your preferences and share your printer. This is sometimes […]

Crontab

Monday, January 10th, 2005

I have been having a lot of difficulty using Moveable Type in recent weeks. This has slowed progress on the website. I’ve made the switch to Wordpress which is a php alternative to the perl powered Moveable Type. I have found it to be a very nice editor that is very easy to install and […]

Restart Classic

Wednesday, November 17th, 2004

Here is a shell script you can use to shutdown and restart classic. I created this to run as a cron script, so that I could shut down classic at an interval. It seemed like Classic was having memory problems if it ran too long without a reboot, so I set it up to run […]

terminal mount command

Thursday, October 7th, 2004

I’ve been trying to understand the mount command in Unix. If anyone can shed some light on it, please do post. This is what I have figured out. You can mount an afp volume using the command mount -t afp. But you first have to establish a share point for the mount to land. So […]

printing a directory list

Thursday, August 26th, 2004

One thing that OS X is lacking that I used all of the time in OS 9 is the print window command in the finder. There are a few ways to get around this limitation. One way is to open the window you want a print out of. Grab the icon at the top middle […]

softwareupdate

Monday, August 16th, 2004

Apple has provided a command line utility to match the Aqua software update. This can be scripted to run and also can be run remotely using ssh.
I ran the softwareupdate command by typing in softwareupdate -i -r for install required. The discovery of this command line command is really rather nifty. Next time you need […]

Script to mount a server

Tuesday, July 27th, 2004

In OS X you use the Go menu to Connect to a server. If you have installed the Script menu that comes with Applescript in your Applications folder you can place an applescript in there that will be a shortcut to mounting an often used server. Below is a script you can use:
tell application “Finder”
–activate
try
mount […]

Perl File::Copy and Apple’s ditto command

Wednesday, July 21st, 2004

You can use Perl’s File::Copy module to move files around your system. The only drawback is that if the files are macbinary and have a resource fork, that portion of the file gets lost. You can use Apples ditto command with –rsrc parameter to move files and maintain the resource.
Following is a perl subroutine I […]

Using Applescript with PERL

Sunday, July 18th, 2004

One of the great advantages of OS X is that you can control applications using Applescript. There is a command line version of calling applescript called osascript. The really cool thing is being able to use this command inside of another script such as a perl script or a shell script. One of the things […]

Using Perl to change file names

Friday, July 16th, 2004

The previous tip showed how you can change filenames in a given directory uisng the command line. If you need to use perl to programatically change file names you can use the rename perl function. Often times I need to iterate through a directory and change names of files based on a given condition. Here […]