macdevcenter.com
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Unix Gems for Mac OS X
Pages: 1, 2, 3, 4

The Remind program has a few options for producing text-based and Postscript calendars. The first is the -c[n] option, which causes Remind to produce a text-based calendar, which it writes to stdout.

If you specify a number (n), Remind generates a calendar with that many months, beginning with the current month. If you do not specify n, Remind generates a calendar for the current month only.

The -p[n] option cause Remind to generate a Postscript calendar. Like the -c syntax, adding a n will cause Remind to generate a calendar with that many months.

In addition to these options, you can also use other programs to generate different calendar formats. For example, you can use Remind in conjunction with the rem2html.pl script to generate an HTML calendar.

Now that you understand the basics, let's look at an example of using Remind and cal. The script pim.pl is a simple example of how you can combine these tools to create a useful program. The PIM script enables you to keep a contact list, your calendar, a word list, notebook, and a quote database using freely available programs.

To run the program, download the script, cd to the directory that holds the script, edit the constants at the top of the file, and type:

% perl pim.pl

If you run this within screen, you can keep your calendar on one machine and access it from any host connected to the Internet.

Finally, the text-based pim script is useful as is, but is easily extendable to other implementations. For example, I have re-implemented it as a CGI and use it as an online pim.

GNUPlot -- An Interactive Plotting Program

Installation: http://fink.sourceforge.net/

So far, we've looked at two pretty useful applications. The final program I will present has been around for since the mid-1980s. GNUPlot is a program you can use to generate plots and charts. Unlike many plotting programs, GNUPlot is a "command driven" program.

For example, in a program like Excel, you create your data, select it, and tell Excel to plot the data, in some format. GNUPlot, on the other hand, is command driven. This means you tell GNUPlot what data to plot and how to plot it by issuing commands.

The power of this approach is that you can issue commands in several ways. You can enter commands interactivity within the GNUPlot program, you can store plot commands and data in files and have GNUPlot process the files from the command line, or you can access GNUPlot programmatically from scripting languages such as Perl and Python, as well as other languages.

Another plus is that you can create a batch of plots and save them to files. This is really useful when controlling GNUPlot programmatically. Finally, you can even control GNUPlot from AppleScript.

Let's begin by creating some interactive plots. Open a Terminal window and type gnuplot at the prompt.

You'll see some program information and be left at a prompt. You use this prompt to enter commands that drive the plotting process. Also, notice above the prompt the line "Terminal type set to 'aqua'." This tells you that plots will be generated for display using the AquaTerm.

You can tell GNUPlot to generate plots in different formats. For example, plots do not have to be displayed on the screen in a window. Instead, you can save them as Postscript or JPEG files. This is great for batching processing plot data.

Let's start by creating a simple plot of the sin function. To do this first open a Terminal window and type gnuplot at the prompt. next, type the following command:

gnuplot> plot sin(x) 

Since the terminal is set to aqua, the plot is displayed in a window. Let's change the output format to Postscript and generate the same plot.


gnuplot> set term postscript 
gnuplot> plot sin(x)

Instead of the plot coming up in a window, it's generated in Postscript. To get a list of the available terms, type help terminal at the GNUPlot prompt. See the documentation for information on adding more terminal types.

Pages: 1, 2, 3, 4

Next Pagearrow