5 =head1 NAME $RCSfile: clearexec.pl,v $
7 Execute commands on the remote system
15 Andrew DeFaria <Andrew@ClearSCM.com>
23 Mon Dec 13 09:13:27 EST 2010
27 $Date: 2012/04/27 14:47:22 $
33 Usage clearexec.pl: [-u|sage] [-ve|rbose] [-deb|ug]
34 [-h|ost <host>] [-p|ort <port>] [<cmd>]
37 -u|sage: Displays usage
40 -deb|ug: Output debug messages
42 -h|ost <host>: Host to contact (Default: localhost)
43 -p|ort <port>: Port to connect to (Default: 25327)
44 <cmd> Command to perform
48 This script exercises the clearserver.pl daemon by executing a command on the
49 remote host:port that the clearserver.pl daemon is running on
58 use Term::ANSIColor qw(color);
60 use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
67 my $VERSION = '$Revision: 1.11 $';
68 ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
70 my $me = $FindBin::Script;
75 my $host = $Clearexec::CLEAROPTS{CLEAREXEC_HOST};
76 my $port = $Clearexec::CLEAROPTS{CLEAREXEC_PORT};
83 my $prompt = color('BOLD YELLOW') . "$me->$host:" . color('RESET');
85 $CmdLine::cmdline->set_prompt($prompt);
87 while (($line, $result) = $CmdLine::cmdline->get()) {
88 last unless defined $line;
89 last if $line =~ /exit|quit/i;
91 my ($status, @output) = $clearexec->execute($line);
93 last if $line =~ /stopserver/i;
96 error "Non zero status returned from $line ($status)\n" . join "\n", @output;
98 display join "\n", @output;
99 display "Status: $status"
109 'usage' => sub { Usage },
110 'verbose' => sub { set_verbose },
111 'debug' => sub { set_debug },
114 ) or Usage "Invalid parameter";
116 my $cmd = join ' ', @ARGV;
118 verbose "$FindBin::Script V$VERSION";
120 $clearexec = Clearexec->new;
122 my ($status, @output);
124 $status = $clearexec->connectToServer($host, $port);
126 error "Unable to connect to $host:$port", 1 unless $status;
129 ($status, @output) = $clearexec->execute($cmd);
132 error "Unable to execute $cmd (Status: $status)\n" . join("\n", @output), 1;
134 display join "\n", @output;
135 display "Status: $status";
143 =head1 CONFIGURATION AND ENVIRONMENT
145 DEBUG: If set then $debug is set to this level.
147 VERBOSE: If set then $verbose is set to this level.
149 TRACE: If set then $trace is set to this level.
157 L<Getopt::Long|Getopt::Long>
159 =head2 ClearSCM Perl Modules
172 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearexec.pm">Clearexec</a><br>
173 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
174 <a href="http://clearscm.com/php/scm_man.php?file=lib/Utils.pm">Utils</a><br>
179 =head1 BUGS AND LIMITATIONS
181 There are no known bugs in this script
183 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
185 =head1 LICENSE AND COPYRIGHT
187 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.