script

A shell script to search multiple jar files for a Java class or pattern

I've found that there are several times when I need to be able to find a Java class inside of a jar file. Usually this happens when something isn't working, and I get something like a Java ClassNotFoundException. In the process of debugging this problem -- especially if I'm using a jar library that I haven't used before -- I list the contents of one or more jar files to debug the problem.

The beginning of a MySQL database script

Here is some code that I use at the beginning of a MySQL database script to (a) create a database, (b) create a local user to access that database ('foo_user'@'localhost'), (c) create a remote user that can access the database ('foo_user'@'%'), and (d) then use that database (which I need to do before starting a bunch of CREATE TABLE statements):

A Bourne shell script that loops through all files

Linux shell script for loop FAQ: Can you share an example of a Linux shell script for loop, for instance, to do something for every file in the current directory?

Here's a shell script that you'll find on all the Unix, Linux, and Mac OS X computers I've worked on. The general process of this script is "for every file in the current directory do XYZ".

Ant WAR task - A sample Ant build script that builds a WAR file

You'll probably have to know a little bit about Java, Ant, and build files for this sample build.xml file to be any use to you, but if you're looking for a sample Ant build script that can be used to create a war file, or one that simple uses a war task, this example might work for you.

I'm not going to provide any explanation of any of this right now, but if I have time in the future I'll come back here and add a few comments about how this build script works.

How to set the default input focus on a field in an HTML web form

When I create a web-based user interface I tend to be a fanatic about making sure that the first input field on a form gets input focus when the form is first displayed. It always drives me crazy when I go to a web form that requires text input, but the developer of the page hasn't taken the time to put the default focus in the first field of the form.

So ... after looking around at some HTML/JSF/Struts/JSP code I've written over the last few years, the following JSF example shows the most concise way I know of setting default input focus on an HTML form field:

How to run an AppleScript from the Mac OS X Unix shell

AppleScript FAQ: How can I run an AppleScript script from the Mac Unix terminal (Unix command line)?

A cool thing about Mac OS X is that you can run AppleScript programs from the Unix shell. (Well, I guess it's cool if you're a Unix user.)

Running an AppleScript program from the Unix shell turns out to be surprising easy. For instance, if my current working directory has a script named OpenUrls.scpt in it, I can run that script from the command line like this:

Syndicate content