Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

gunzip - not read from a terminal error

Status
Not open for further replies.

unixwhoopie

Programmer
May 6, 2003
45
US
I have a .dat.gz file. When I use 'gunzip' command on the prompt, it works just fine. The file is unzipped as .dat

However when I use the same command from a script, it gives the following error -

gunzip: compressed data not read from a terminal. Use -f to force decompression.

Any ideas? I changed the permission level to 777 and still the same problem.

Thanks
 

It sounds like gunzip if trying to read from stdin, you're not calling it with the -c option, are you?
 
Is xxx.dat an existing file when the script is run trying to gunzip xxx.dat.gz ?
Is the file xxx.dat.gz a real gzipped file ?
From gzip.info:
`-f' Force compression or decompression even if the file has multiple links or the corresponding file already exists, or if the compressed data is read from or written to a terminal. If the input data is not in a format recognized by `gzip', and if the option -stdout is also given, copy the input data without change to the standard ouput: let `zcat' behave as `cat'. If `-f' is not given, and when not running in the background, `gzip' prompts to verify whether an existing file should be overwritten.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
I tried both gunzip -c file.dat.gz and
gunzip -f file.dat.gz in my script, and I still get the same message.

The gz file in the correct format because it works from the command prompt. I only get the error message when running from the script. I am not sure what 'compressed data not read from a terminal' means. Any more ideas?

Thanks a lot

 
Actually when I tried 'gunzip -f', the process was taking too long and I had to kill after 10 mins. I verified there is no previous copy of the .dat file.

Thanks
 
My guess is that you are using a variable in your script that is not set, e.g...
[tt]
# file=""
# gunzip $file > filename
gunzip: compressed data not read from a terminal. Use -f to force decompression.
For help, type: gunzip -h
[/tt]
Also...
[tt]
# gunzip -f $file > filename
[/tt]
....hangs trying to decompress data read from a terminal.
 
I tried "gunzip -c file.dat.gz > file.dat".

ygor, I am not sure what you meant. I declared the target file as file.dat and also specified its path, I still get the same error.

Surprisingly, it works fine on the command line but does not work from a shell script. I am not sure what the difference is.

Thanks all for your replies.
 
To be sure, please post your script

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Thanks...I figured this out...It was a variable reading error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top