I'm driven crazy by a new problem.
It seems very complex to me and I see no way to come around.
In my script, I receive the path to a tgz file and I want to output the md5 sum of the file inside the tgz. I want a way to detect if tar fails.
I'm using the following command
If the tgz contains a regular file, this command returns its md5 sum.
If the tgz contains an empty file, it returns d41d8cd98f00b204e9800998ecf8427e.
If the tgz is corrupted, it will also return d41d8cd98f00b204e9800998ecf8427e.
Invoking the error code will not help because it will return the one of the last command which is cut.
How would you do that? I need to output the md5sum of the zipped file (empty or not) and I want something else (empty, error code, whatever) if the tgz is corrupted.
Thanks bartus11
Your script works indeed.
The thing is that I'm working with big files and I wanted to avoid using tar twice.
A simple tar -tzf can take up to 4 seconds. Files are processed one by one and your script would double the time necessary to complete all files.
If you find any other way to avoid that, it would be great.
Thanks anyway for your proposal.
Santiago
---------- Post updated at 18:52 ---------- Previous update was at 18:36 ----------
Actually, I need to invoke tar twice in my script and I wanted to avoid invoking it three times.
First time I get the md5sum, second time, I read the statistics from tar -t.
Then I insert those informations in a database.
So here is what I did:
Thx for your help
You can untar that file to /tmp and then calculate md5 checksum:
This code won't produce any output if tar file is corrupted, as md5sum won't even lauch in case tar fails.
Alternatively, in ksh93 and bash you can use pipefail, so that the RC at the end of pipes is the value of the last non-zero command to fail or zero if no command has failed.
output:
Last edited by Scrutinizer; 06-24-2010 at 03:38 AM..
Hi,
I am using Jenkins and have integrated JMeter for testing. JMeter is generating a file with results properly using shell script. I have to validate the results and exit the shell with non-zero so my jenkins job gets failed. I tried multiple ways to grep the output file and read the results... (2 Replies)
Hello,
Is there any API or any other approach to detect whether the network cable is connected to the network adapter, say, en0, en1 or en2?
The OS is AIX6.1.
Thank you. (4 Replies)
There is a same named log file that I have on my 2 different android phones. When I plug it into my computer, it appears in the media folder, For example the first android phone:
/media/F6BA-0AF5/folder/A.log
I want to put that into a variable to be manipulated.... (3 Replies)
I write a script which will stop an application, then restart it.
Sometimes it is succesful, sometimes not.
The problem is, when stop the application, some ports are still listenning (or not released). When start the application, it reports that ports are used, and can't continues.
I use... (1 Reply)
Hi
The Autosys job that call DOS batch file which in turn calls java and this java program has successful completion though there are series of exception occurred in the data it handles and want the job to be set to Fail in its autosys, how could it be done?
a.bat
{
java sample.class
... (1 Reply)
Hi all,
understood that upon executing a script, we can get various in-built variable like:
$? => Exit status
$$ => Process PID
${0##*/} => Process ID Name
Is there any readily available lookup table as to what are the available status variablee, and what do they mean...
Thanks in... (2 Replies)
hi,
exit status variable $?, returns some digits.
0 ---> succes.
1..126
Failure (the program itself will decide what the numbers mean)
127
Command not found
128..254
The program did not exit normally. (E.g., it crashed, or received a signal)
255
Invalid exit code
well, if $?... (4 Replies)
I have successfully installed RedHat 8.0 onto a Dell PowerEdge SC1425 today. This server has two SATA hard drives, and an IDE DVD-ROM drive.
Using the following kernel parameters, i successfully installed across both hard drives from CD:
ide0=0x1f0,0x3f6,14 vga=791 resolution=1024x768 expert... (5 Replies)
I'm having an issue when I export within my program. I'm getting the variable name, not the variable value. I have a configuration file (config.txt) that has the values of the variables set as so:
set -a
export ARCHIVEPOSourceDir="/interfaces/po/log /interfaces/po/data"
export... (2 Replies)