0

So running into an issue with my code here not sure what exactly i'm doing wrong i pass it the two arguments it searches for the file but its always going to does not exist.

i pass this to the file

perl restore.cgi users_old_52715.tar.gz Ace_Walker

its not finding the file it exist i assure you.

#!/usr/bin/perl
use Archive::Tar;

my $tarPath    = $ARGV[0];
my $playerfile = $ARGV[1].".ini";



my $tar = Archive::Tar->new($tarPath);
if ($tar->contains_file($playerfile)) {
    $tar->read($tarPath);
    $tar->extract_file($playerfile, './' );
    print "Successfully restored $playerfile to production enviroment\n";
    exit 0;
}else{
    print $playefile." does not exist in this archive!\n";
    exit 0;
}
Alex B
  • 13
  • 3

2 Answers2

0

Just writing Scott Hunter's comment as an answer:

Try using an absolute path instead of a relative one.

Community
  • 1
  • 1
0
if( $tar->extract_file($playerfile, './'.$playerfile )){ 
  print "Successfully restored $playerfile to production enviroment\n";
}
exit 0;

man Archive::Tar :

$tar->extract_file( $file, [$extract_path] )
Write an entry, whose name is equivalent to the file name provided to disk. Optionally takes a second parameter, which is the full native path (including filename) the entry will be written to.

AnFi
  • 10,493
  • 3
  • 23
  • 47