in reply to Re^3: Archive::Tar from somewhere outside my runtime directory
in thread Archive::Tar from somewhere outside my runtime directory

It's working now - needs the chdir function, not tar->cwd!
chdir($vsvroot); foreach my $vsvxdb (<cntl/*>) { $tar->add_files($vsvxdb); } $tar->write("$vsvroot/tmp/cntlbkup.tar");
I think that the doc is actually telling me that tar->cwd is relevant only for extraction, not for creation.

Replies are listed 'Best First'.
Re^5: Archive::Tar from somewhere outside my runtime directory
by Anonymous Monk on Jan 24, 2012 at 06:01 UTC
    <lots of rude words of frustration!> It's NOT working. The example I had working was doing it running standalone but the production version has to run as a task called under another app. The code below never gets away from the application's run time directory even though they're both branches under the same root.
    $vsvroot = $config{$ServerX . "ROOT"}; chdir($vsvroot); MsgLog ("d", "vsvroot = $vsvroot"); MsgLog ("d", cwd()); foreach $vsvxdb (<cntl/*>) { MsgLog ("d", "Add $vsvxdb to tarfile\n"); if (! $tar->add_files($vsvxdb)) { MsgLog ("e", "Failed to add original $vsvxdb to backup + archive. Quitting.") } }
    The log shows...

    vsvroot = "C:\LRSROOT\vsvxroot"

    C:/LRSROOT/vpsxroot

    Add cntl/ckpt.dat to tarfile

    Which lines above correspond to the three MsgLog function calls in the sample code. Note that the vsvroot variable (I left the $ off in the log message) uses backslashes and points to the vsVxroot folder but the print of cwd() shows the vPsxroot folder - same parent, different subfolders. The perl code is called from and app who's root is vPsxroot. I've tried this with a simple test script and it definitely still calls tar from the working directory which is not changed by chdir(). I'm very confused!

      Above post was mine. I got mysteriously anonymised.