Archive for the 'Unix' Category
Thursday, July 14th, 2005
Previously I showed a php script to send email. You can use php as a shell language as well as a web development language. PHP has ready made functions for this, so it is kind of an easy thing to do. Here is an example of a straight email shell script using bash.
#!/bin/bash
sendmail=”/usr/sbin/postfix”
recipient=”user@domain.com, user2@domain2.com”
( cat […]
Posted in General, Shell Script, Unix | 3 Comments »
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 […]
Posted in General, Mac OS X general, Unix | No Comments »
Wednesday, March 16th, 2005
If you have BBEdit and you have installed the command line tool you have a real nice resource for printing lists of file directories. Even without the command line you can drag a directory into a BBEdit window and create a file list of that directory. With the command line tool you can pipe standard […]
Posted in General, Shell Script, Unix | 1 Comment »
Wednesday, March 9th, 2005
Here is a little script I wrote that you can use to move a list of files. Supply it a list of file names. In this case the file names I was supplied didn’t have .pdf on them, so I had to concatentate that onto the file names. I’ve covered this earlier with respect to […]
Posted in General, Perl, Unix | 3 Comments »
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 […]
Posted in Apache, General, Mac OS X general, Unix | 6 Comments »
Monday, February 21st, 2005
I like to have a local copy of my website. With Wordpress, I write directly into my hosted site. So I have to occassionally ftp my host site to my local drive to keep them in sync. I have asked my site host to backup my sql database weekly. Then I can download it to […]
Posted in General, Shell Script, Unix | 6 Comments »
Thursday, February 10th, 2005
I use vi for editing my httpd.conf and other config files as well as for some c programming and shell programming. One of the things I never really used well was the interaction with the shell inside of vi. If you are like me and quit vi to do some shell commands and then reopen […]
Posted in General, Shell Script, Unix | 1 Comment »
Monday, January 17th, 2005
In the terminal, if you find yourself needing to move back and forth between two directories and don’t want to type in the complete path name constantly, you can either set up aliases of the cd command to the directory or you can use pushd. Let’s say you are in your Sites folder in […]
Posted in General, Shell Script, Unix | No Comments »
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 […]
Posted in General, Mac OS X general, Shell Script, Unix | 4 Comments »
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 […]
Posted in General, Mac OS X general, Shell Script, Unix | 3 Comments »
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 […]
Posted in General, Mac OS X general, Shell Script, Unix | 1 Comment »
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 […]
Posted in General, Mac OS X general, Shell Script, Unix | No Comments »
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 […]
Posted in General, Mac OS X general, Shell Script, Unix | No Comments »
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 »