#!/usr/bin/perl
#---------#---------#---------#---------#---------#---------#---------#---------
#
# Title
#   archive a load of vignette projects
# Author
#   idc@planetlarg.net 15 aug 01
# Description
#   this script takes a load of vignette project IDs. Capture the output when
#   you run it eg.
#      cat projects.txt | this-script.pl > this-script.log 2>&1
#   Extract a vignette project into a directory
#   Tar the directory
#   Remove the directory
#   Repeat for all projects we are passed.
#
#   Use system calls when printing information. If you use "print" then the
#   messages will appear AFTER all the system commands have finished.
#   Use the second hex part of the project name as the filename because
#   it is unique.
#---------#---------#---------#---------#---------#---------#---------#---------


    $dir = "/vgnshare/StoryServer/R4.2/bin/solaris";
    chdir $dir or die "can't chdir to $dir";

LINE:
while (<>) {
    chomp;
    $proj = $_;
    s/\/pr\/(.+)/$1/; # extract the second hex part

# export
    system ("echo ./transferproject -o export -l admin:passw0rd -b 10.216.106.132:5100:$proj -p /tmp/$_ ");
    system (
"./transferproject -o export -l admin:passw0rd -b 10.2.3.132:5100:$proj -p /tmp/$_"
    );
    system ("echo");
    sleep 2;

# archive
    system ("echo tar -cvf /tmp/$_.tar /tmp/$_ ");
    system ("tar -cvf /tmp/$_.tar /tmp/$_");
    system ("echo");
    sleep 2;

# remove
    system ("echo rm -rf /tmp/$_");
    system ("rm -rf /tmp/$_");
    system ("echo");
    sleep 2;

}

