#!/usr/bin/perl

#
# PROJECT
#          Hinode/EIS
# PURPOSE
#          Perl script, which runs on the SSH2@ISAS machine, that
#          calls the eis_eisco_archive.pl script (via ssh) on the
#          EISCO machine.
# CATEGORY
#          EIS Timeline Planning/Remote Planning
# WRITTEN
#          John Rainnie & Matthew Whillock
# HISTORY
#          v0.1 JAR 9-Sep-2008
#               Added header
#

use Env qw(HOME);

print "++++++++++++++++++++++++++++++++++++++++++++++++\n";
print "Starting eis_ssh2_archive.pl script on SSH2\@ISAS\n";
print "\n";
#print "Remote planner is $ARGV[0]\n";
print "    Remote planner is SSH2\n";

#$marker  = "$HOME/scp_marker.txt";
$archive = "$HOME/eis_rp_archive.tar.gz";
#system("/bin/rm $marker")  if -e $marker;

# Delete tarball "eis_rp_archive.tar.gz" if it already exists!
system("/bin/rm $archive") if -e $archive;

print "    Logging into EISCO and running the archive script...\n";
system("ssh eisco\@eisco eis_eisco_archive.pl");

#$limit = 600;
#while($limit-- > 0) {
#    sleep 1;
#    if(-e $marker) {
#	print "Copying archive tar file to remote planner's machine ($ARGV[0])\n";
#	system("scp $archive $ARGV[0]");
#	last;
#    }
#}

print "\n";
print "Finished eis_ssh2_archive.pl script on SSH2\@ISAS\n";
print "++++++++++++++++++++++++++++++++++++++++++++++++\n";

