script

Bash shell script - how to prompt and read user input

Unix/Linux bash shell script FAQ: How do I prompt a user for input from a shell script (Bash shell script), and then read the input the user provides?

Answer: I usually use the shell script "read" function to read input from a shell script. Here are two slightly different versions of the same shell script. This first version prompts the user for input only once, and then dies if the user doesn't give a correst Y/N answer:

A PayPal PHP IPN example

If you're looking for a PayPal IPN example written in PHP, I believe the following code works okay. It's based on the PayPal PHP IPN example (from the PayPal developer site), but I fixed some bugs from their example, added an alternate PHP socket example so you don't have to use SSL to connect to PayPal, and added more variables to the script.

A Unix shell script to rename many files at one time

Summary: A Unix/Linux shell script that can be used to rename multiple files (many files) with one shell script command.

Problem

You're on a Mac OS X, Unix, or Linux system, and you'd like to be able to rename a large number of files at once. In particular, you'd like to be able to change the extensions of a large number of files, such as from *.JPG to *.jpg (changing the case of each file extension from upper case to lower case).

A better test for detecting Unix operating systems in an Ant build script

In several previous tutorials (see my references below) about testing for operating systems within Ant build scripts, and then conditionally executing targets based on the results of those tests, I noted that Mac OS X operating systems respond to both Mac and Unix test conditions based on the Ant "os family" test. I mentioned that I thought this behavior was probably correct, because Mac OS X is built an a Unix base (BSD, to be specific).

A Ruby script to remove binary (garbage) characters from a text file

Problem: You have a file that should be a plain text file, but for some reason it has a bunch of non-printable binary characters (also known as garbage characters) in it, and you'd like a Ruby script that can create a clean version of the file.

Solution: I've demonstrated how to do this in another blog post by using the Unix tr command, but in case you'd like a Ruby script to clean up a file like this, I thought I'd write up a quick program and share it here.

Ant - How to use a date or timestamp in an Ant build script

Summary: An Ant date and timestamp (tstamp) task example.

I was just digging through some Ant build scripts I've created, and I noticed a segment of a build script that first creates a timestamp, and then uses that timestamp in the process of creating a manifest file. (This build script is used for building a Java Swing application.)

Here's the code from my Ant script that does this timestamp magic:

How to turn a list of jar files into an Ant classpath string

Summary: Using a list of jar files to create a dynamic classpath to write to a manifest file in an Ant build script.

In this tutorial I'd like to demonstrate how to convert a list of jar files in a standard lib directory into a classpath string you can use to define a manifest file in an Ant build script. By converting this list of jar files into a classpath string, the build process for your jar file can depend on any number of external jar files, and you can create this classpath dynamically.

Syndicate content