Core API
This is the bits which you will need to get started...
A connection to the EPrints system is represented by an instance of EPrints::Session. The session object links to
- the configuration of the repository (only one per session object, even if the system itself has multiple repositories).
- the database for the repository.
- the language to output in.
And if a CGI script then also
- the EPrints::DataObj::User object of the current user, if any.
- the apache request.
If you're writing your own script then you'll need to start by asking for a Session object.
Command-line Script
#!/usr/bin/perl -w -I/opt/eprints3/perl-lib/ use EPrints; use strict; my $archive_id = $ARGV[0]; my $session = new EPrints::Session( 1, $archive_id ); exit( 1 ) unless( defined $session ); # do your stuff $session->terminate;
The "1" passed to Session tells it that we're a normal script and not a CGI script.
The $archive_id value is taken from $ARGV[0] which is the first parameter on the commandline. You could hard-wire the value if you wanted.
The use of "-w" to produce warnings and "use strict" to prevent sloppy code is just good Perl-practice.
CGI Script
This is similar to a command line script but you don't need the path to perl and the archive_id is not needed as it will work that out from the web-request.
use EPrints;
use strict;
my $session = new EPrints::Session; exit( 0 ) unless( defined $session );
# do some stuff
# Return a result to browser (usually an HTML page) $session->terminate();