Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: foreach loop to untar multiple files

by stevieb (Canon)
on Nov 13, 2015 at 17:16 UTC ( [id://1147678]=note: print w/replies, xml ) Need Help??


in reply to Re: foreach loop to untar multiple files
in thread foreach loop to untar multiple files

Carefully look at your output... the file path is being specified twice... tar: /home/user/results//home/user/results/results_back.tar.gz. Try this:

for (@tar){ print `tar -tvf $_`; }

ps. I'd recommend you look at my Archive::Extract example here, to avoid having to shell out.

Replies are listed 'Best First'.
Re^3: foreach loop to untar multiple files
by afoken (Chancellor) on Nov 13, 2015 at 17:59 UTC
    for (@tar){ print `tar -tvf $_`; }

    Quite dangerous. Imaginge a file named "foo ; rm -rf * ; bar.tar.gz", injected into @tar by ls or glob. (And yes, that's a legal filename.)

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re^3: foreach loop to untar multiple files
by fasoli (Beadle) on Nov 13, 2015 at 17:22 UTC

    Thanks for your answer. I noticed that the file path is specified twice, that's why I said that I tried to delete $results and only go for $_. However this was obviously wrong as it hangs for a few seconds and fails quietly and I was wondering if anybody knew why. The same happens with the script you provided :(

    I will look at the Extract example in more detail, it just scared me a bit as it looked a little more complicated.

      My example *should* be good to go, just update the path info in the variables. If you try it and you have issues, reply back and we'll help you through it :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-19 20:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found