Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Calling pax within a perl script (was stupid substitution question)

by viffer (Beadle)
on Aug 11, 2010 at 11:56 UTC ( #854336=note: print w/replies, xml ) Need Help??


in reply to Re: Calling pax within a perl script (was stupid substitution question)
in thread Calling pax within a perl script (was stupid substitution question)

Thank you - appreciate your help. Whilst this works perfectly for
my $cmd = q{pax -r -f /home/kev/pax.tar -s'/\/home\/kev\/pax\//\/data\/kev\/atlanta\/emtex\/invoices\//p'};

When the directory name has several nodes and the filename being paxed/untarred is a variable I guess it isn't interpolating correctly

$command= q{pax -r -f $file -s'/DirPart1.DirPart2.DirPart3/SubDir\//\/data\/kev\/atlanta\/emtex\/invoices\//p'};

I have tried several variants of this, such as
$command= q{pax -r -f $file -s'/DirPart1\.DirPart2\.DirPart3\/SubDir\//\/data\/kev\/atlanta\/emtex\/invoices\//p'};
When running this I get the error:
A file or directory in the path name does not exist.
which makes me think the string isn't being interpolated correctly.
I can see how using a different delimiter would obviate the need for using backslashes in the first example that works,
but in the second example don't I need escape backslashes for the '.' if not for the subdir '/'?

Replies are listed 'Best First'.
Re^3: Calling pax within a perl script (was stupid substitution question)
by JavaFan (Canon) on Aug 11, 2010 at 12:14 UTC
    $file won't interpolate inside q{}. A handful of alternatives:
    • $command = "pax -r -f $file -s'!DirPart1.DirPart2.DirPart3/SubDir/!/data/kev/atlanta/emtex/invoices/!p'"
    • $command = qq{pax -r -f $file } . q{-s'/DirPart1.DirPart2.DirPart3\/SubDir\//\/data\/kev\/atlanta\/emtex\/invoices\//p'};
    • $command = sprintf q{pax -r -f %s -s'/DirPart1.DirPart2.DirPart3/SubDir\//\/data\/kev\/atlanta\/emtex\/invoices\//p'}, $file;
    • $command= q{pax -r -f $file -s'/DirPart1.DirPart2.DirPart3/SubDir\//\/data\/kev\/atlanta\/emtex\/invoices\//p'}; $command =~ s/\$file/$file/;
    Or something else.
      Thanks VERY much for your help. *Finally* got this to work

      $file =~ s/TGZ/tar/; $dir = $file; $dir =~ s!\.S75\.T...tar!\/Invoices\/!; if ($file =~ /(PROD.OPTBL.X.K.)(R*)(.S75.T11.tar)/) { $run=$2; } $command = "pax -r -f $file -s'!$dir!/data/kev/atlanta/emtex/invoi +ces/R$run/!p'";

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2022-05-29 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (101 votes). Check out past polls.

    Notices?