#!/usr/bin/perl

my $hostname = `hostname`;

($suffix, $rest) = $hostname =~ m/d-(\d+)\.cs\.wisc\.edu/;

#$realsuffix = sprintf "%02d", $suffix;
print "$suffix\n";
my $realsuffix = $suffix + 0;
printf "real suffix is $realsuffix\n";

my $dir = shift;

#my $cmd = "/unsup/hadoop-0.16.0/src/hadoop-0.16.0/bin/hadoop fs -copyFromLocal /scratch/tpch_data/1000/lineitem.tbl." . $realsuffix . " /user/epaulson/lineitem.tbl." . $realsuffix;
my $firstcmd = "/unsup/hadoop-0.16.0/src/hadoop-0.16.0/bin/hadoop fs -copyFromLocal " . $dir . "/lineitem.tbl.* /user/epaulson/lineitems/";
my $secondcmd = "/unsup/hadoop-0.16.0/src/hadoop-0.16.0/bin/hadoop fs -copyFromLocal " . $dir . "/customer.tbl.* /user/epaulson/customers/";
my $thirdcmd = "/unsup/hadoop-0.16.0/src/hadoop-0.16.0/bin/hadoop fs -copyFromLocal " . $dir . "/orders.tbl.* /user/epaulson/orders/";

print "I'm going to run $firstcmd\n";
`$firstcmd`;
print "I'm going to run $secondcmd\n";
`$secondcmd`;
print "I'm going to run $thirdcmd\n";
`$thirdcmd`;
