Operating System - HP-UX
1833061 Members
3212 Online
110049 Solutions
New Discussion

Re: Too many resources required when I use "gzip"

 
Curtelin
Advisor

Re: Too many resources required when I use "gzip"

Please A. Clay Stephenson, could you help me using your script ?

I'm not really sure to understand how it works...I don't know perl language...
I use the command "gzip toto.tar" to obtain the file "toto.tar.gz" : but how to "integrate" these parameters in your perl script ?

Thanks a lot !
A. Clay Stephenson
Acclaimed Contributor

Re: Too many resources required when I use "gzip"

First, I would change the "shbang" entry back to "#!/usr/bin/perl -w" and then create a symbolic link from the actual perl executable to /usr/bin/perl.

e.g. "ln -s /opt/perl/bin/perl /usr/bin/perl"

/usr/bin is a much more standard location and if you create the symbolic link, all of your future Perl scripts will be much more portable.

----------------------------------------
"./cppause.pl gzip toto.tar"

You really messed this up. Note that I said that this Perl script reads standard input (in binary) and outputs to standard output. In your case, stdin is your terminal and so is sdout so it will wait until your type a Ctrl-D (EOF).

Here is how you should have done it and created a pipeline:

cppause.pl < toto.tar | gzip > toto.tar.gz

Now if you wanted to specify read 20 chunks at a time of 32768 bytes and pause 3 seconds between each 20 chunks then the command would be:

cppause.pl -b 32768 -p 20 -s 3 < toto.tar | gzip > toto.tar.gz

Of course, had you bothered to "cppause.pl -u", you would have seen this for yourself.
If it ain't broke, I can fix that.
Curtelin
Advisor

Re: Too many resources required when I use "gzip"

Thanks you very much...
Well I read the help of the command but I didn't remember how to "work" with stdin...
In fact, I tried the command :
"cppause.pl < gzip toto.tar > toto.tar.gz"
I knew it was not the good command...almost the good one !!! I forgot the pipes :)

Curtelin
Advisor

Re: Too many resources required when I use "gzip"

Could I use the script for the command "tar" too ?
For example :
"cppause.pl < toto | tar cvf > toto.tar"
(toto is a directory...)

I'm going to try immediately !

(And the command "vi" to edit a big big text file ?)
A. Clay Stephenson
Acclaimed Contributor

Re: Too many resources required when I use "gzip"

No tar expect a list of files or directories but the following would work and throttle your i/o.



tar cvf - toto | cppause.pl > toto.tar

Note the "-" following f; this tells tar to write on stdout. Since you are trying to do this with tar, this suggest that your problems extend beyond gzip.

You really need to have someone who understands UNIX look at your applications and the system configuration because "fix'es" like throttling i/o should not be needed.
If it ain't broke, I can fix that.
Curtelin
Advisor

Re: Too many resources required when I use "gzip"

well please I still need explications :)
"cppause.pl < toto.tar | gzip > toto.tar.gz" means :
1) "toto.tar" is the entry (stdin) for "cppause.pl"
2) "| gzip" means the result of the "first step" is "sent" (piped) to the command "gzip"
3) "> toto.tar.gz" means the stdout of the "gzip" is the file "toto.tar.gz"

Is it the "good" explication ?

Why can I not use the syntax :
"gzip toto.tar | cppause.pl > toto.tar.gz" ? (like the syntax you give me for "tar")
Is it because "gzip toto.tar" is not the "good" entry (stdin) ? It's the file "toto.tar" which is the good one for the script cppause.pl, isn't it ?
In fact I have difficulties to understand the syntax you give me for the command "tar"...because it seems there is no stdin anymore for the perl script, no ?


A. Clay Stephenson
Acclaimed Contributor

Re: Too many resources required when I use "gzip"

well please I still need explications :)
"cppause.pl < toto.tar | gzip > toto.tar.gz" means :
1) "toto.tar" is the entry (stdin) for "cppause.pl"
2) "| gzip" means the result of the "first step" is "sent" (piped) to the command "gzip"
3) "> toto.tar.gz" means the stdout of the "gzip" is the file "toto.tar.gz"

Is it the "good" explication ?

A. YES, ALL OF THAT IS CORRECT.
---------------------------------------

Why can I not use the syntax :
"gzip toto.tar | cppause.pl > toto.tar.gz" ? (like the syntax you give me for "tar")
A. THE SHORT ANSWER IS THAT IT IS WRONG.

If I "gzip toto.tar" that tells gzip to read the file toto.tar and rewrite it as toto.tar.gz. Nothing is written on stdout.

It might make more sense to you if I rewrite
cppause.pl < toto.tar | gzip > toto.tar.gz
to this:
cat toto.tar | cppause.pl | gzip > toto.tar.gz

Both forms are equivalent but the cat is unnecessary and because another process must be spawned, it is less efficient -- but it might be a clearer form for you to grasp.

You really need to find a basic shell scripting book and study input/output redirection. None of this is actually related to Perl, it is nothing more (and nothing less) than shell i/o redirection.
You should also study the gzip and tar man pages to understand the behavior when these utilities interact with stdin and stdout.






If it ain't broke, I can fix that.
Curtelin
Advisor

Re: Too many resources required when I use "gzip"

Yes...really thanks for your help...
Well I work using Unix but just a little bit :) I'm discovering...