Sponsored Content
Top Forums Shell Programming and Scripting set a variable and detect error status... Post 302431991 by chebarbudo on Wednesday 23rd of June 2010 11:42:05 AM
Old 06-23-2010
Question set a variable and detect error status...

Hi there,

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
Code:
tar -xzOf "$1" 2>/dev/null | md5sum | cut -b-32

  • 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.

Can you help me?
Cheers
Santiago
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Export command giving Variable Name vs the Value set for the Variable

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)
Discussion started by: ParNone
2 Replies

2. Red Hat

Installing RedHat 8.0 onto Dell PowerEdge SC1425 - hdc: status error: status = 0x58

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)
Discussion started by: fishsponge
5 Replies

3. UNIX for Dummies Questions & Answers

$? = Exit status variable

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)
Discussion started by: dummydba
4 Replies

4. UNIX for Dummies Questions & Answers

Environment Status Variable

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)
Discussion started by: srage
2 Replies

5. Windows & DOS: Issues & Discussions

Autosys unable to set the job to the status of FAILED

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)
Discussion started by: muthupus
1 Replies

6. Shell Programming and Scripting

how to detect port open status?

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)
Discussion started by: rdcwayx
1 Replies

7. HP-UX

What is the use of command set -- and set - variable?

Hi, I am using hp unix i want to know the use of the following commands set -- set - variable thanks (4 Replies)
Discussion started by: gomathi
4 Replies

8. Shell Programming and Scripting

script to detect a file from inserted usb and puts into a Variable

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)
Discussion started by: tobenguyen
3 Replies

9. AIX

How to detect the network cable status with c programming on AIX

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)
Discussion started by: zephyrbj
4 Replies

10. Shell Programming and Scripting

Detect error and exit

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)
Discussion started by: sitaram
2 Replies
VFU(1)								 VFU File Manager							    VFU(1)

NAME
vfu - VFU is console (text-mode) file manager for UNIX/Linux SYNOPSIS
vfu [options] DESCRIPTION
vfu has following features: - Fast one-key commands - Extended completition and wildcard expansion - Directory tree with sizes (incl. sizes cache) - File-type colorization (extension and type) - Archives support (TAR, TGZ, BZ2, and many more) - Simple FTP support through archive-like interface - Internal text/hex file viewer and editor (optional) - Extensive user-defined external support/utils - Regular expressions selection and search - Multiple file masks - and much more... OPTIONS
-h prints help for command line options -i runs vfu in interactive mode (can be used with -d) -d path changes working directory to `path' -r rebuild directory tree -t view directory tree only These options are for using vfu in partial non-interactive mode. example: vfu -d /usr/local -i CONFIGURATION
vfu configuration is divided in two parts (files): vfu.conf This file contains configuration for external editor and pager, favorite directories, file-type colorization. This is plain text file which format is described below. vfu only reads vfu.conf, it never writes in it! vfu.options This file contains all Options/Toggles which can be changed from inside vfu -- Options menu. vfu.options is binary file and is overwritten on vfu exit or on change option event! Deleting this file will reset vfu toggles to default values. vfu.options is not portable between vfu versions! Location of vfu.conf vfu.conf can be placed as any of: $HOME/.vfu/vfu.conf $HOME/$RC_PREFIX/vfu/vfu.conf (if $RC_PREFIX is exported) /etc/vfu.conf /usr/local/etc/vfu.conf /usr/local/vfu.conf Other files location All other files including vfu.options are placed in: $HOME/.vfu/ $HOME/$RC_PREFIX/vfu/ What is "$RC_PREFIX" and why to use it? Some more information for this can be found in the CONFIG file which is supplied with vfu package. VFU.CONF This is a sample copy of vfu.conf with appropriate comments: DISTRIBUTION
It is supposed that only source packages will be distributed. However sometimes binary packages will be released, but not often. VFU packages are named in this way: vfu-X.xx.src.tgz source package for version X.xx vfu-X.xx.bin.platform.tgz binary package for version X.xx for `platform' platform examples: vfu-4.00.src.tgz vfu-4.00.bin.linux.glibc.tgz vfu-4.00.bin.linux.libc5.tgz vfu-4.00.bin.dos.tgz All packages are TAR+GZIP .tgz, bz2 and zip are available on request. NOTE: Always check HISTORY document -- it often contains some usefull notes! FILES
$HOME/$RC_PREFIX/vfu/vfu.conf configuration, explained above $HOME/$RC_PREFIX/vfu/vfu.options options, explained above $HOME/$RC_PREFIX/vfu/vfu.history contains history lines $HOME/$RC_PREFIX/vfu/vfu.tree contains directory tree If you don't set $RC_PREFIX configuration files are: $HOME/.vfu/vfu.conf $HOME/.vfu/vfu.options $HOME/.vfu/vfu.history $HOME/.vfu/vfu.tree TODO
see the TODO file BUGS
unknown AUTHOR
Vladi Belperchinov-Shabanski "Cade" <cade@biscom.net> <cade@datamax.bg> http://cade.datamax.bg/ http://cade.datamax.bg/vfu/ 3rd Berkeley Distribution Version 4.00 VFU(1)
All times are GMT -4. The time now is 01:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy