NAME
CGI::AppBuilder::Net - Methods used for remote commands and network
SYNOPSIS
my $self = bless {}, "main";
use CGI::AppBuilder::Net;
$self->debug_level(2); # set debug level to 2
# The level 3 message will not be displayed
$self->echo_msg("This is level 1 message.", 1);
$self->echo_msg("This is level 2 message.", 2);
$self->echo_msg("This is level 3 message.", 3);
DESCRIPTION
The package contains the modules can be used for executing UNIX commands
or initiate network connections.
new (ifn => 'file.cfg', opt => 'hvS:')
This is a inherited method from CGI::AppBuilder. See the same method in
CGI::AppBuilder for more details.
exec_cmd ($cmd, $pr)
Input variables:
$cmd - a full unix command with paraemters and arguments
$pr - parameter hash ref
remote_host - Remote host name or ip address
local_host - local host name or ip address
remote_usr - Remote user name
remote_pwd - Remote user password
Variables used or routines called:
get_params - get values for multiple parameters
How to use:
use CGI::AppBuilder::Net qw(:all);
# Case 1: hosts are different and without id and password
my $cmd = "cat /my/dir/file.txt";
my $pr = {datafax_host=>'dfsvr',local_host='svr2'};
my @a = $self->exec_cmd($cmd,$pr); # uses rsh to run the cmd
# Case 2: different hosts with id and password
my $pr = {datafax_host=>'dfsvr',local_host='svr2',
datafax_usr=>'fusr', datafax_pwd=>'pwd' };
my @a = $self->exec_cmd($cmd,$pr); # uses rexec
# Case 3: hosts are the same and just open a file
my $pr = {datafax_host=>'dfsvr',local_host='dfsvr'};
my $ar = $self->exec_cmd('/my/file.txt',$pr); # case 2:
# Case 4: hosts are the same and run a program
my $pr = {datafax_host=>'dfsvr',local_host='dfsvr'};
my $ar = $self->exec_cmd('cat /my/file.txt',$pr); # case 2:
Return: array or array ref
This method opens a file or runs a command and return the contents in
array or array ref.
CODING HISTORY
* Version 0.10
Extracted exec_cmd from DataFax::StudySubs.
* Version 0.11
No there yet.
FUTURE IMPLEMENTATION
* no plan yet
AUTHOR
Copyright (c) 2007 Hanming Tu. All rights reserved.
This package is free software and is provided "as is" without express or
implied warranty. It may be used, redistributed and/or modified under
the terms of the Perl Artistic License (see
http://www.perl.com/perl/misc/Artistic.html)