Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Creating Tarballs in a perl scripts

by morgon (Deacon)
on Jun 11, 2012 at 15:55 UTC ( #975598=note: print w/ replies, xml ) Need Help??


in reply to Creating Tarballs in a perl scripts

First of all: Do you really want the outout of tar?

If not you should not use backticks but system.

Then it all depends on what your variables acually contain as the string you use inside the backticks will be interpreted by a shell.

If for example your $DEST variable contains "/tmp/*" then it is clear why no hidden files make it to the tar-archive - the shell globs "*" and will not pass any hidden files to tar.

The shell used in backticks is usually /bin/sh (not bash - bash-settings are irrelevant here).

If your $DEST does not contain shell meta-characters then I cannot see any reason why your command should not work, but that would not be a Perl-related problem.

Finallly if you use system you can avoid a shell by calling it like

system("/bin/tar", "-cfz", $output_file, $directory)


Comment on Re: Creating Tarballs in a perl scripts
Select or Download Code
Re^2: Creating Tarballs in a perl scripts
by Lotus1 (Chaplain) on Jun 11, 2012 at 19:39 UTC

    First of all: Do you really want the outout of tar?

    If not you should not use backticks but system.

    Perhaps the OP doesn't want to see the output on the display.

      Perhaps the OP doesn't want to see the output on the display.
      IMO it would be natural (and easier to understand) in this case to redirect to the bit bucket...


      -- 
      Ronald Fischer <ynnor@mm.st>
Re^2: Creating Tarballs in a perl scripts
by mdw1982 (Initiate) on Jun 12, 2012 at 16:54 UTC

    First, thank you all for your replies; much appreciated as this has been bugging me for quite some time.

    Morgan, your solution was just what I needed, interestingly though when I tried using system() before I couldn't get it to work as I wanted. Implementing the way you exampled did the trick.

    At first it wasn't working correctly, but that led me to a glaring error in the code that I'd been missing. All is fixed now and working nicely.

    Thank you all for your assistance.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2014-12-26 09:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (170 votes), past polls