- if ($cmd) {
-
- my ($path, $fcmd);
-
- # first expand out the entry to a command
- ($path, $fcmd) = search($main::localcmd, $cmd, "pl");
- ($path, $fcmd) = search($main::cmd, $cmd, "pl") if !$path || !$fcmd;
+#
+# this is the thing that runs the command, it is done like this for the
+# benefit of remote command execution
+#
+
+sub run_cmd
+{
+ my $self = shift;
+ my $user = $self->{user};
+ my $call = $self->{call};
+ my $cmdline = shift;
+ my @ans;
+
+ if ($self->{func}) {
+ my $c = qq{ \@ans = $self->{func}(\$self, \$cmdline) };
+ dbg('eval', "stored func cmd = $c\n");
+ eval $c;
+ if ($@) {
+ return (1, "Syserr: Eval err $errstr on stored func $self->{func}");
+ }
+ } else {
+
+ # strip out //
+ $cmdline =~ s|//|/|og;
+
+ # split the command line up into parts, the first part is the command
+ my ($cmd, $args) = $cmdline =~ /^([\w\/]+)\s*(.*)/o;
+
+ if ($cmd) {
+
+ my ($path, $fcmd);
+
+ # alias it if possible
+ my $acmd = CmdAlias::get_cmd($cmd);
+ if ($acmd) {
+ ($cmd, $args) = "$acmd $args" =~ /^([\w\/]+)\s*(.*)/o;
+ }
+
+ # first expand out the entry to a command
+ ($path, $fcmd) = search($main::localcmd, $cmd, "pl");
+ ($path, $fcmd) = search($main::cmd, $cmd, "pl") if !$path || !$fcmd;
+
+ my $package = find_cmd_name($path, $fcmd);
+ @ans = (0) if !$package ;
+
+ if ($package) {
+ my $c = qq{ \@ans = $package(\$self, \$args) };
+ dbg('eval', "cluster cmd = $c\n");
+ eval $c;
+ if ($@) {
+ @ans = (0, "Syserr: Eval err cached $package\n$@");
+ }
+ }
+ }
+ }