Scripted wrappers for legacy applications
Let's start with an easy example, the kind you'll want to do on your own: create a C source file, test1.c:
#include
#include
main()
{
struct timeval timevalue;
struct timezone timezone;
gettimeofday(&timevalue, &timezone);
printf("The current time is %s",
ctime((time_t *) &timevalue.tv_sec));
}
and make an executable program from it. Under Unix, you'd generally do that with a command-line invocation:
cc -o test1 test1.c
Now create the Perl/Tk source file, test1.pl:
use Tk;
$mw = MainWindow->new;
$label = $mw->Label();
$label->pack;
$mw->Button(-text => "Show the time",
-command => sub{
$label->configure(-text => `./test1`)
})->pack;
MainLoop;
There! If you execute:
perl test1.pl
you'll see a small GUI panel with a button. Pushing the button launches the C-coded program, retrieves output, and displays it. The problem's solved, for both Unix and Windows.
There's more to the story
For many programmers, though, that is only the beginning. Let's look at the example in more detail.
To run the example, we launch a Perl program, which itself controls the legacy test1 as a separate process. With all the examples in this article, it doesn't matter that test1 is compiled from C source; it could be a Fortran, C++, Java, or even another Perl program. All that matters in that architecture is that it can be launched as a command-line application, which puts its results to standard output.
Most modern languages available for Unix and Win* have at least one way of invoking an external process and retrieving its result in that way. The gluing languages we discuss in this column are particularly rich in those facilities. Most accessible to beginners
Symantec Backup Exec 12 and Backup Exec System Recovery 8 deliver industry leading Windows data protection and system recovery. Download this whitepaper to find out the top reasons to upgrade and how to get continuous data protection and complete system recovery.
Data and system loss — from a hard drive failure, malicious attack, natural disaster, or simple human error — can happen anytime. Don’t leave your business vulnerable. Make sure you have a secure recovery strategy in place. Symantec's latest backup and system recovery technology can efficiently restore critical applications, individual emails and documents and even restore your entire system in minutes in the event of a loss.
Businesses face a growing challenge to ensure that the IT environment is properly protected. Backup Exec 12 integrates with other applications in the Symantec family of products, to complement your current data protection strategy, keep your data securely backed up and make it recoverable when you need it most.







