Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Archive::Tar from somewhere outside my runtime directory

by GrandFather (Saint)
on Dec 12, 2011 at 06:30 UTC ( [id://943029]=note: print w/replies, xml ) Need Help??


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

Nope. Reading the docs it looks like setcwd is pure optimisation and that the cwd has to be set for relative paths to do what you expect. However there is an implication that absolute paths are unaffected by such silliness. So, you have two options ...

True laziness is hard work

Replies are listed 'Best First'.
Re^4: Archive::Tar from somewhere outside my runtime directory
by murrayn (Sexton) on Dec 12, 2011 at 21:38 UTC
    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.
      <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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://943029]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-03-29 00:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found