Error when unzipping a file with extension .gz


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error when unzipping a file with extension .gz
# 15  
Old 11-21-2013
Actually, I downloaded the report from a merchant's website and it usually downloads in the same format. Earlier, we used to extract the file on Windows, then place it on our FTP server location. From this location, my ETL tool picks up the file and loads it into our company Database. Since this process involves a lot of manual intervention, I am trying to automate the process as much as I can. For this reason, I was currently figuring out a process on how to extract the txt file present in the compressed file. The file uncompress quickly and easily using a winzip program... Still need help doing it in Linux, so I would at least avoid the extraction part... What I can then do is, directly download the file from the website and place it on my FTP location and the rest is taken care by the script...
# 16  
Old 11-21-2013
Still, I do not know how you transferred the raw .gz file from Windows onto UNIX. If you transferred the file to UNIX with FTP, it's possible you transferred it in ASCII mode rather than binary mode. The feature is designed to translate native Windows \r\n newlines into native UNIX \n newlines. This is useful for uncompressed text but you can probably imagine it'd be disastrous in binary data, where \n does not mean a new line!

If you are uploading with FTP, issue the binary command before you put anything.

Last edited by Corona688; 11-21-2013 at 05:28 PM..
# 17  
Old 11-21-2013
I FTPd using Winscp to transfer the file that I downloaded from the merchant's web portal into Linux location. winzip works and extracts the file very easily, but I am having trouble using unzip command too... Even this is giving me an error as following.

Code:
Archive:  D_R_38957222_20111410.txt.gz
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of D_R_38957222_20111410.txt.gz or
        D_R_38957222_20111410.txt.gz.zip, and cannot find D_R_38957222_20111410.txt.gz.ZIP, period.

Code:
file D_R_38957222_20111410.txt.gz

gives me output as
Code:
D_R_38957222_20111410.txt.gz: gzip compressed data, from FAT filesystem (MS-DOS, OS/2, NT)


Do not understand why gunzip command doesnt uncompress the data in the file when the file command says it is compressed using gzip
# 18  
Old 11-21-2013
Again, I suspect the file was transferred in ASCII mode which corrupted it. This is a common pitfall with FTP. You would never notice this problem transferring raw text, but it will scramble anything else!

The file command only checks the first few bytes of the file to make a reasonable guess at what kind it is. Most binary files begin with a type code, header, or something. It wouldn't notice any corruption that happened later.

Last edited by Corona688; 11-21-2013 at 06:19 PM..
This User Gave Thanks to Corona688 For This Post:
# 19  
Old 11-22-2013
If the file were a regular .gzfile, then any one of your solutions might have worked I guess... this file might be corrupted like you said and since the file uncompresses easily using winzip, also I do not know how to check if the file is corrupted or not, I am stuck with the issue. I did not know how the filecommand worked, thank you for helping on the issue, I still haven't figured out any solutions to it though... Will definitely find an answer and post the answer here so someone else might benefit from it
# 20  
Old 11-22-2013
Quote:
Originally Posted by dhruuv369
If the file were a regular .gzfile, then any one of your solutions might have worked I guess... this file might be corrupted like you said and since the file uncompresses easily using winzip, also I do not know how to check if the file is corrupted or not, I am stuck with the issue. I did not know how the filecommand worked, thank you for helping on the issue, I still haven't figured out any solutions to it though... Will definitely find an answer and post the answer here so someone else might benefit from it
For the third time, check whether your FTP client is uploading in ASCII mode -- this will scramble any non-text file!

You could also try an alternate method of uploading it, like SCP. All SCP transfers are binary, there is no ASCII mode to turn off.
# 21  
Old 11-25-2013
@Corona688: I have checked under the FTP client's (WinSCP) settings and the transfer mode is set to Text(Plain text, html, scripts,....) I do not think it is uploading the files in ASCII mode. Also attached is the screenshot of the settings window
Error when unzipping a file with extension .gz-scpjpg
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unzipping .Z file in UNIX

Hi , How can I unzip a .Z file in Unix? Thanks and regards, Anupam (3 Replies)
Discussion started by: Anupam_Halder
3 Replies

2. Shell Programming and Scripting

Error while Unzipping

Hi, I have transfered a Zip file from Windows to Unix and tried to Unzip it in Unix using ksh. But it throws an error: error : missing 24 bytes in zipfile (attempting to process anyway) error : attempt to seek before beginning of zipfile (please check that you have transferred or... (2 Replies)
Discussion started by: angie1234
2 Replies

3. Shell Programming and Scripting

Unzipping the file

I have my folder structure like a file a.zip is placed in one folder. Inside a.zip is two other zip files x.zip and y.zip If i unzip x.zip i have folder a folder z and inside folder z there are different folders with event time appended to it. Inside the every event folder ,I have a sub folder... (1 Reply)
Discussion started by: weknowd
1 Replies

4. Linux

unzipping file > 2gb

I am not able to unzip file greater then 2gb, Any suggestions how to do that in linux? Regards, Manoj (5 Replies)
Discussion started by: manoj.solaris
5 Replies

5. Shell Programming and Scripting

Unzipping latest zip file by name.

I have these zip files that come in with the same name, but different versions. We'll say: SQL_version2.zip SQL_version3.zip SQL_version2432.zip I was wondering if there is a single command (or even piped command, thus still making it a single command) that will let me unzip the latest... (3 Replies)
Discussion started by: mrwatkin
3 Replies

6. Solaris

Alter zip file without unzipping

I have some zip files. Every file has a "folder/xml file" inside it. Is there any way to change these zip files directly without unzipping them. I want to convert these zip files to "/xml file" (want to move the xml file/s one root up by removing the folder inside it.) Ex: -bash-3.00$ for file... (1 Reply)
Discussion started by: _prasad
1 Replies

7. HP-UX

Error while UNZIPPING

Hi, I have file.zip in windows machine, i moved that .zip to unix throught ftp. when i tried to unzip the .zip file getting the error. please see the below information for the same. I am using the below command to UNZIP : unzip /users/test/file.zip /users/test/test111 Below are the... (1 Reply)
Discussion started by: srujana
1 Replies

8. UNIX for Dummies Questions & Answers

reading a zipped file without unzipping it?

Dear all, I would like to ask how i can read a zipped file (file.gz) without actually unzipping it? i think there is a way to do so but i can't remember it.. can anyone help? thanks in advance.. (1 Reply)
Discussion started by: marwan
1 Replies

9. Shell Programming and Scripting

How to search a pattern inside a zipped file ie (.gz file) with out unzipping it

How to search a pattern inside a zipped file ie (.gz file) with out unzipping it? using grep command.. Bit urgent.. pls..help me (2 Replies)
Discussion started by: senraj01
2 Replies

10. UNIX for Dummies Questions & Answers

unzipping .zip file on HP and Solaris

I am transferring a large .zip file (20 GB) from an NT server to HP-UX and Solaris servers. Originally I tried to use info-zip's unzip, but I found out pretty quickly that it does not support files over 4GB. Any suggestions on how to work around this problem? Different decompression utility?... (9 Replies)
Discussion started by: dangral
9 Replies
Login or Register to Ask a Question