Archive for the 'Unix' Category

Using smb and rsync to backup

Monday, January 28th, 2008

I needed a script to backup a workfolder to a Windows network server. I wrote this perl script that can be triggered using cron. First create a mount point. I used /smb/public. So to do so in two steps, mkdir /smb, then mkdir /smb/public. I put my scripts in ~/bin. Put this perl script below […]

Universal Password Manager

Saturday, December 15th, 2007

I have been wanting a way to carry my passwords around with me. I purchased a USB card. The next step was to find a way to easily manage the passwords on the disk. After much searching, I found a java application, that has been written to work nicely with Mac OS X. It is […]

/usr/bin/head and perl lwp

Tuesday, July 24th, 2007

I use cpan to install perl modules all the time. I recently installed Perl LWP. Unfortunately the install replaces and important text command file in /usr/bin. The file head was replaced by LWP head and this has caused some problems on my system. I found it out when I tried to install Sun’s Netbeans IDE […]

Using Perl to build a table of images

Monday, July 16th, 2007

I had a very large folder of images that I needed to build a tale of, as well as links for the images. I wrote a perl script to read the directory and build the table based upon the image file names in the folder. For our purposes here I am simplifying the script.

#!/usr/bin/perl
use File::Copy;
my […]

Drupal up and running

Wednesday, June 6th, 2007

Well, I implemented my bradrice.com front page to a drupal driven site. Please check it out. Drupal seems to live perfectly fine with any other pages you are serving or software living in the root folder. I decided for sanity sake to install it in a drupal folder and redirect to it. That way I […]

regex for path names

Saturday, February 24th, 2007

May seem simple to most folks, but just in case you are looking for an expression to remove the path before a file name here is an expression to start.
[\w/]*/
It searches for all the word characters before the last slash. If you need periods in the path add those to the character class.

LAMP or MAMP? on mac

Wednesday, January 31st, 2007

I just updated my LAMP (Apache, MySql and PHP). I found that PHP installation can become problematic with MySql 5. Apparently the mac binary doesn’t include shared libraries. PHP fails when you build it against mysql. So I googled and found this excellent resource for helping you step through the installations. Start with Mysql and […]

Using Perl references for developing

Wednesday, January 3rd, 2007

I found a good way to make use of a scalar reference in perl. For development when you are using a dev and live server, you can change some settings using a ref.
Here’s what I did recently. In this case I needed two different mount scripts, one for a dev server and one for a […]

.net on Mac?

Monday, September 4th, 2006

One thing nice about Mac OS X are the avenues for development. There is Perl, PHP, Python, Ruby, C, Objective C, java, javascript, applescript and shell, just to name some of the possibliities. One of the things I have always wanted to be able to do, was to write .asp and test it on Mac […]

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 […]

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 […]

plists and launchd

Sunday, February 26th, 2006

Recently I wrote about getting Tomcat running in Mac OS X. You can easily start it up manually anytime you want by running the startup script in /Library/Tomcat/bin after you have it installed. But if you want it or any other daemon to run at startup you can use launchd if you are running Tiger. […]

Getting Tomcat running

Saturday, February 18th, 2006

I’ve recently made the foray into AJAX. I purchased the Apress book “Foundations of AJAX.” When I went to download the source code that went with the book it required me to have tomcat running to view it using a java servlett. I decided to install Tomcat. It was simple, but it wasn’t simple […]

grep through files

Thursday, January 26th, 2006

I have occasion to look for various text inside of files in a directory. Grep is great for that. To look for some text in a whole directory of files you can type on the command line grep matchtext *.txt. That will pull up the files with the matched text and print it out on […]

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 […]

Using Perl to compare two directories

Friday, December 16th, 2005

If you ever need to compare two directories to find files missing from one that are in the other, perl can be a good utility to use. You can read into two arrays two directories, then create a hash using the second directory array as keys (this should be the smaller directory). Then use the […]

Name based virtual hosts

Tuesday, November 15th, 2005

I’ve revised a previous tip here with regard to setting up your mac to server virtual hosts to use your mac for development of sites. I find this to be a little easier than using 127.0.0.1 as your virtual host. Instead find the virtual host portion (usually at the bottom) of your httpd.conf file which […]