next up previous contents index


30.2.15 Final example

To round off, the following program example illustrates a simple session with WebDMS in the Perl language:

use strict;
use LWP::UserAgent;
use HTTP::Cookies;
my $server = "http://localhost/perl/avclient/index.pl"; 
my $connect = "?host=localhost&db=archivista&uid=Admin&pwd=archivista";
my $www = LWP::UserAgent->new; # new www session 
$www->cookie_jar(HTTP::Cookies->new('file'=>'/tmp/cookies.lwp','autosave'=>1));
my $res = $www->get("$server$connect"); # connect to webdms 
if ($res->is_success) {
  if ($res->content) { # we got login
    my $cmd = "?go_query&fld_Seiten=3"; # search for 3 pages
    $res = $www->get("$server$cmd");
    my $cmd = "?go_doc_next";
    for (my $c=1;$c<=18;$c++) { # navigate 18 times to next doc
      $res = $www->get("$server$cmd");
    }
  }
}

The above example creates a connection with WebDMS, executes a search query in which all files with three pages are activated and then navigates through 18 files. Furthermore, when a script is called externally, it is important that the 'cookies' are saved. This is the only way in which further 'commands' can be transferred to WebDMS.