Archive for July, 2004
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 […]
Posted in Applescript, General, Mac OS X general | 1 Comment »
Friday, July 23rd, 2004
Here is a little perl script that you can use to lowercase text with an uppercase first letter of each word. If you put it in your BBEdit unix filters it will work on any selected text.
#! perl -w
use strict;
while () {
tr/[A-Z]/[a-z]/;
s/\b([a-z])/\u$1/g;
print $_;
}
Posted in General, Perl, Unix | 1 Comment »
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 […]
Posted in General, Mac OS X general, Perl, Unix | 2 Comments »
Tuesday, July 20th, 2004
Sometimes applications crash, or at least they don’t behave the way they should. The kill command will come in handy when you need to kill an application. I use this command to find the Distiller pid then kill it:
kill -9 $(ps -auxwww | grep Distiller | grep -v grep | awk ‘{print $2}’)
One of the […]
Posted in General, Shell Script, Unix | 1 Comment »
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 […]
Posted in Applescript, General, Mac OS X general, Perl, Unix | Comments Off
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 […]
Posted in General, Mac OS X general, Perl, Unix | Comments Off
Thursday, July 15th, 2004
Here I am changing a whole directory of file names. I am changing the extension of any file with the .tif extension to .jpg.
ls *.jpg | awk ‘{print(”mv “$1″ “$1)}’ | sed ’s/.jpg/.tif/2′ | /bin/sh
Of course you can change the sed regular expression to change it to whatever you want to change the file names […]
Posted in General, Mac OS X general, Shell Script, Unix | 1 Comment »
Wednesday, July 14th, 2004
To use the terminal to print a postscript page of a man page use these commands:
groff -Tps -man /usr/share/man/man7/groff.7 | lpr -P LaserWriter_8500
I’m using an Apple Laserwriter 8500. To find the printers available to your lpr command use the command lpstat -a to list them. If there isn’t a printer available, you will need to […]
Posted in General, Mac OS X general, Shell Script, Unix | 2 Comments »