Perl Scripts讨论
希望大家能将经验共享!
Genesis now supports Perl scripts
=================================
How to enable Perl scripts under Genesis
========================================
The following steps are needed to enable Perl scripts under Genesis:
1. Obtain Perl
2. Install Perl
3. Install the Perl files enabling sockets
4. Change /etc/services
5. Inspect the files in /genesis/eNN/all/perl
6. Install Genesis.pm
7. Read rules regarding Perl scripts
8. Run the example script
9. Debugging
10. Remote debugging
Obtaining Perl
==============
You have to have a recent version of Perl available on your
computer. Version 5.003 is recommended.
There are many sites where you can obtain Perl.
One example site is
ftp://sunsite.auc.dk/pub/languages/perl
but there are many more.
Install Perl
============
You need to unzip the perl tar file, read the INSTALL file,
run Configure, and then run make. You will also need a C compiler.
Install the Perl files enabling sockets
=======================================
Once Perl has been installed, you must ensure that you run the Perl
program h2ph. This creates a number of Perl files which are necessary
to enable the use of sockets.
cd /usr/include; h2ph * sys/*
Change /etc/services
=====================
You will need to add the following line to the file /etc/services
genesis 56753/tcp # Genesis port for scripts
so that the correct socket number is used.
Inspect the files in /genesis/eNN/all/perl
==========================================
Have a look in the directory /genesis/eNN/all/perl, where NN is the
version number. You will find the following files:
Genesis.pm
server.pl
example.pl
Genesis.pm is the interface from Perl to Genesis and must be used in
all scripts.
server.pl is the script to run from Genesis to allow perl scripts to
be debugged.
example.pl is an example of a Perl script.
All these files are scripts and are readable.
Install Genesis.pm
==================
Genesis.pm is a Perl library, and as such, Perl must know where to
find it. The simplest option is to install the file in the site_perl
directory which is under the lib/perl/site_perl directory of wherever
yo have installed Perl.
Alternatively, you can leave it where it is and define the global
variable PERLLIB to point to the correct directory. Or, you can define
the library area by placing the line
use lib qw(/genesis/e30/all/perl) ;
before "use Genesis" in your script.
See the Perl manual for a fuller description of these options.
Read rules regarding Perl scripts
=================================
All scripts that interface to Genesis must contain the lines
!# /usr/local/bin/perl
use Genesis ;
at the beginning.
!# /usr/local/bin/perl <-- This must be the correct path for your installation
use Genesis ; <-- This defines the interface to Genesis
$f = new Genesis ; <-- This starts up the connection to Genesis
Then you can use COM, VOF etc just like in csh with some minor syntactic differences.
To use VOF, just say $f->VOF ;
To use COM, $f->COM("the command you want") ;
In addition, I have added some sample functions that might prove useful. These are
o getJobs, which gets the list of jobs
o getLayers, which gets a list of layers for a job
o getSteps, which gets a list of steps for a job
Invocation is as follows:
@jobs = $f->getJobs() ; # This list is put into @jobs
@getSteps = $f->getSteps($myJob) ; # Gets a list of steps for the job
@getLayers = $f->getLayers($myJob,$myLayer) ; # gets the layers for a given job and step
The interface is very similar to the csh interface, and an example of
usage can be found in the file example.pl.
It is essential that any perl script contains the word "perl" in the
first line, otherwise Genesis will think that it is a csh and do the
wrong thing.
Once the script is ready, you just run the script like any other
script. But don't use the csh debugger to try to debug Perl scripts,
because it won't work.
Run the example script
======================
Run the script example.pl exactly as you would a csh script and see what results it produces.
Debugging
=========
Perl has it's own native, very powerful debugger which you can use. If
you have a script you want to debug, you first have to run the script
server.pl from Genesis.
Once this script has been run, Genesis waits for commands from your
Perl script. To start your own perl script you must open a shell such
as xterm, hpterm, emacs and run the command
perl -d example.pl
This puts you into perl debug mode, and you can single step from there.
Incidentally, you don't have to use the -d option. Without it, the
script simply runs to completion.
Remote debugging
================
Because communication between the perl script and Genesis uses sockets, it is just as easy to run the perl script from a remote computer.
On the remote computer you type
perl -d example.pl hostName
where hostName is the name of the computer running Genesis, and you
will be able to debug the application remotely.
If you have any questions regarding the Genesis interface to Perl, can
email me at
Note: you will need to add the line to /etc/services on the computer
running perl.
genesis 56753/tcp # Genesis port for scripts
More Documentation
==================
The Genesis.pm is self-documented using pod.
BUGS
====
If you try to run the script server.pl and you receive the message
************IMPORTANT NOTICE *********
The port has not been defined. To define it you need to
become root and add the following line in /etc/services
genesis 56753/tcp # Genesis port for scripts
**************************************
then you need to set up /etc/services.
-----------------------------------------------------------------
If you receive the following output then the file scr_start.csh is not up
to date and doesn't work with perl scripts.
=head: Command not found.
Set: Command not found.
Most: Command not found.
=cut: Command not found.
use: Command not found.
use: Command not found.
sub: Command not found.
sub: Command not found.
ARGV: Undefined variable.
-----------------------------------------------------------------
瞧瞧```
抄的。00000000000000000000000
呵呵,,G里面自带的。
不错啊
不错啊
不错啊
不错啊
不错啊
不错啊
不错啊
不错啊
不错啊
不错啊
路过而以....