Meta

 view release on metacpan or  search on metacpan

Meta/Baseline/Rsh.pm  view on Meta::CPAN

#sub TEST($);

#__DATA__

sub rsh($$$$$) {
	my($demo,$verb,$targ,$host,$comm)=@_;
	my($chst)=Meta::Utils::Net::Hostname::part();
	if($demo) {
		return(0);
	}
	my($type)="error";
	my($code)=1972;
	my($foun)=0;
	if(!$foun) { # this is the current machine
		my($currhost)=Meta::Utils::Net::Hostname::part();
		if($host eq $currhost) {
			$type="current";
			$code=Meta::Utils::System::smart_shell($comm);
			$foun=1;
		}
	}
	if(!$foun) { # this is a unix machine which is not the current
#		if(Meta::Baseline::Cook::is_linu($host)) {
		if(1) {
			$type="linux";
			$comm="cd ".Meta::Utils::Chdir::get_system_cwd().";".$comm;
#			$comm=Meta::Baseline::Cook::unix_path($comm,$host,$chst);
			$code=Meta::Utils::System::system_nodie("ssh",[$host,$comm]);
			$foun=1;
		}
	}
	if(!$foun) { # this is a pc machine
#		if(Meta::Baseline::Cook::is_ntxx($host)) {
		if(1) {
			$type="pc";
			my($numb)=$#$targ+1;
			for(my($i)=0;$i<$numb;$i++) {
				my($curr)=$targ->[$i];
				Meta::Utils::File::File::create_new($curr);
				Meta::Utils::File::Prop::chmod_agw($curr);
			}
			my($temp)=Meta::Utils::Pc::get_temp_dir()."/kuku.pl";
			my($resu)=Meta::Utils::Pc::get_temp_dir()."/kuku.res";
#			$comm=Meta::Baseline::Cook::pc_path($comm,$host,$chst);
			my($curr)=Meta::Utils::Chdir::get_system_cwd();
#			$curr=Meta::Baseline::Cook::pc_path($curr,$host,$chst);
			Meta::Utils::Pc::writ_perl_inte($comm,$resu,$temp,$curr);
			my($rcom)="perl $temp $resu";
#			$rcom=Meta::Baseline::Cook::pc_path($rcom,$host,$chst);
			$code=Meta::Utils::System::system_nodie("rsh",[$host,$rcom]);
			my($scod);
			Meta::Utils::File::File::load($resu,\$scod);
			if($scod) {
				$code=$scod;
			}
			Meta::Utils::File::Remove::rm_soft($temp);
			Meta::Utils::File::Remove::rm_soft($resu);
			if($code) {
				for(my($i)=0;$i<$numb;$i++) {
					my($curr)=$targ->[$i];
					Meta::Utils::File::Prop::chown_curr($curr);
					Meta::Utils::File::Remove::rm($curr);
				}
			} else {
				for(my($i)=0;$i<$numb;$i++) {
					my($curr)=$targ->[$i];
					Meta::Utils::File::Prop::chown_curr($curr);
					Meta::Utils::File::Prop::chmod_rgw($curr);
				}
			}
			$foun=1;
		}
	}
	if(!$foun) { # machine not found
		throw Meta::Error::Simple("unknown machine [".$host."]");
	}
	Meta::Utils::Output::verbose($verb,"data is [".$demo."] [".$verb."] [".$host."] [".$comm."] [".$type."]\n");
	my($ncod)=Meta::Utils::Utils::bnot($code);
	return($ncod);
}

sub cook_rsh($$$$) {
	my($demo,$verb,$host,$comm)=@_;
	my($inpu)=$comm=~/sh -ce (.*);/;
	my($file)=$comm=~/echo \$\? > (.*)'/;
	my($fcom)=Meta::Utils::File::File::load_line($inpu,1);
	my($rcom,$targ)=$fcom=~/(.*);targets=(.*)$/;
	Meta::Utils::Output::verbose($verb,"[".$targ."] on [".$host."]\n");
	my(@targ)=split(" ",$targ);
	my($code)=rsh($demo,0,\@targ,$host,$rcom);
	my($io)=Meta::IO::File->new_writer($file);
	my($scod)=Meta::Utils::Utils::bnot($code);
	print $io $scod."\n";
	$io->close();
	return($code);
}

sub TEST($) {
	my($context)=@_;
	#my($scod)=Meta::Baseline::Rsh::rsh(0,1,"localhost","echo","Hello,\ World!");
	#return($scod);
	return(1);
}

1;

__END__

=head1 NAME

Meta::Baseline::Rsh - library to do correct rsh execution on machines.

=head1 COPYRIGHT

Copyright (C) 2001, 2002 Mark Veltzer;
All rights reserved.

=head1 LICENSE

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the



( run in 1.557 second using v1.01-cache-2.11-cpan-71847e10f99 )