Cisco Enhanced Device Interface User's Guide, 2.0
Using Perl Scripts

Table Of Contents

Using Perl Scripts

Setting Up a Perl Scripting Session

Perl Script Examples

Deleting a File

Creating a Directory

Deleting a Directory


Using Perl Scripts


Cisco E-DI supports perl scripting through the CLI. This feature automates many of the server and network administration tasks. This section explains how to enable and disable the perl scripting service, and how to use Cisco E-DI Perl API for daily tasks.

When a perl script is implemented by an administrator or a user, the script automatically inherits the user's security privileges and the user's operational context (either server or network).

Each invocation of a perl script will use an additional CLI session for the duration of that script implementation.

This section includes the following information:

Setting Up a Perl Scripting Session

Perl Script Examples

Setting Up a Perl Scripting Session

Table 10-1 details how to setup a perl scripting session.

Table 10-1 Commands to Setup a Perl Scripting Session 

Action
Command

To enable perl scripting service for the CLI. By default it is enabled on Cisco E-DI.

[SRV:/server](config)# service 
perl-scripting

To open a vi editor.

Enter the perl script. Save the script

[SVR:/server]# edit filename.pl

To run the perl script filename.pl located in the ./server directory.

[SRV:/server]# perl /server/filename.pl

To disable the perl scripting service for the CLI.

[SRV:/server](config)#no service 
perl-scripting

Perl Script Examples

This section includes the following examples:

Deleting a File

Creating a Directory

Deleting a Directory

Deleting a File

Perl script to delete a file:

use lib '/perlapi';
use CISCOPERLAPI;
$| = 1;
my $api= CISCOPERLAPI->getAPI ();
unlink("PerlAutoFile.txt")|| die "Cannot delete a file";
$api->closeAPI ();

Creating a Directory

Perl script to create a directory:

use lib '/perlapi';
use CISCOPERLAPI;
$| = 1;
my $api= CISCOPERLAPI->getAPI ();
mkdir("perl",0777) || die "Can not create directory";
$api->closeAPI ();

Deleting a Directory

Perl script to delete a directory:

use lib '/perlapi';
use CISCOPERLAPI;
$| = 1;
my $api= CISCOPERLAPI->getAPI ();
rmdir("remove") || die "Can not remove directory";
$api->closeAPI ();