UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2008-01-22 05:59 AM

Raj Kumar Arora
Member
Registered: 2008-01-03
Posts: 7

Re: strange problem regarding zip/unzip from window to solaris machine

Hi ,

I faced a very strange problem when I unzip a zip file on my solaris workstation. Actually I wanted to transfer a folder, say it TEST which contains some sub-folders inside it from windows to solaris machine. So I zipped this folder to TEST.ZIP on my windows machine.

Then from my windows machine, I started ftp from command prompt and connected to my solaris machine and I copied this TEST.ZIP folder using put command to my solaris mahcine in bin mode.

On my solaris machine, I extracted this folder by following command :-
          $   unzip TEST.ZIP
It unzipped the folder and produced a TEST folder. But the problem is that when I opened any file from any of the sub-folders of this TEST folder using vi editor, in every line it is showing "^M" i.e., control + M character which I dont intended.

Firstly I could not know how these control chars are getting appended. But when I searched on google for solving the problem, I could only find the reason but not its solution. The reason for these control char is that in window every line is terminated by Enter or Return key which in solaris mahcine appeared as these control chars.

Anybody who have any idea, please help me ASAP.

Regards,
Raj Kumar Arora

Offline

#2 2008-01-22 06:11 AM

jfriesne
Administrator
From: California
Registered: 2005-07-06
Posts: 348
Website

Re: strange problem regarding zip/unzip from window to solaris machine

Offline

#3 2008-01-22 06:59 AM

Raj Kumar Arora
Member
Registered: 2008-01-03
Posts: 7

Re: strange problem regarding zip/unzip from window to solaris machine

Sorry my bad luck prevented it from working at my side. The following error message is occurring "SUBSTITUTION PATTERN MATCH FAILED" or "Pattern not found".

Any other option ?

Offline

#4 2008-01-22 07:27 AM

jfriesne
Administrator
From: California
Registered: 2005-07-06
Posts: 348
Website

Re: strange problem regarding zip/unzip from window to solaris machine

CONVERSION

You can use the 'fileformat' option to convert from one file format to
another.  Suppose, for example, that you have an MS-DOS file named README.TXT
that you want to convert to UNIX format.  Start by editing the MS-DOS format
file:
	vim README.TXT

Vim will recognize this as a dos format file.  Now change the file format to
UNIX:

	:set fileformat=unix
	:write

The file is written in Unix format.

Offline

#5 2008-01-22 08:18 AM

Raj Kumar Arora
Member
Registered: 2008-01-03
Posts: 7

Re: strange problem regarding zip/unzip from window to solaris machine

Offline

#6 2008-01-22 12:58 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,847
Website

Re: strange problem regarding zip/unzip from window to solaris machine

Yes, the ^M is CR...  On DOS/Windoze, the EOL is CR+LF, whereas on Unix, it's
just LF, so that's why you see stray CRs...

Your system might have a conversion script available, such as "dos2unix", which
can do the conversion...  Or, you can just do this:

tr -d '\r' < file > newfile

Offline

#7 2008-01-23 06:08 AM

Raj Kumar Arora
Member
Registered: 2008-01-03
Posts: 7

Re: strange problem regarding zip/unzip from window to solaris machine

tr -d '\r' < file > newfile

Offline

#8 2008-01-23 11:24 AM

Raj Kumar Arora
Member
Registered: 2008-01-03
Posts: 7

Re: strange problem regarding zip/unzip from window to solaris machine

Offline

#9 2008-01-23 01:59 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: strange problem regarding zip/unzip from window to solaris machine

A bit late perhaps, but unzip itself probably has an option to do the file conversion automatically if needed (the version I'm using has the "-a" option which does it).

Offline

#10 2009-01-27 08:35 AM

Seo Services
Guest

Re: strange problem regarding zip/unzip from window to solaris machine

Great stuff. I learn new thing from your question. Thanks.

Board footer

Powered by FluxBB