strange problem regarding zip/unzip from window to solaris machine

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajarora
    New Member
    • Sep 2007
    • 33

    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
  • ashitpro
    Recognized Expert Contributor
    • Aug 2007
    • 542

    #2
    Originally posted by rajarora
    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
    When you copy files from windows to linux/unix. Carriage returns get appended at each line.
    Use "dos2unix" command. Don't worry it will definitely work.

    Comment

    • rajarora
      New Member
      • Sep 2007
      • 33

      #3
      Originally posted by ashitpro
      When you copy files from windows to linux/unix. Carriage returns get appended at each line.
      Use "dos2unix" command. Don't worry it will definitely work.
      Thanks a lot.The option dos2unix is working but its suitable for only some of the files or only few files as for it the source file name and target file name should be different. So I tried to firstly cp/mv all file like this mv *.cc *.cc.old
      or cp *.cc *.cc.old
      which failed because the cp or mv command failed for * wildcard. I cant manually change for each file as I am having a bunch of files.

      Any alternative ?

      Regards,
      Raj Kumar Arora

      Comment

      • ashitpro
        Recognized Expert Contributor
        • Aug 2007
        • 542

        #4
        Originally posted by rajarora
        Thanks a lot.The option dos2unix is working but its suitable for only some of the files or only few files as for it the source file name and target file name should be different. So I tried to firstly cp/mv all file like this mv *.cc *.cc.old
        or cp *.cc *.cc.old
        which failed because the cp or mv command failed for * wildcard. I cant manually change for each file as I am having a bunch of files.

        Any alternative ?

        Regards,
        Raj Kumar Arora
        Syntax for dos2unix is something like below

        dos2unix <filename>

        It has no source-destination issue.
        you supply one file and it will be converted thats it.
        You can use dos2unix as-

        $ find . -type f -exec dos2unix {} \;

        It will work recursively
        But make sure that your files are text files.
        because this command may corrupt your binaries.

        Comment

        • rajarora
          New Member
          • Sep 2007
          • 33

          #5
          Originally posted by ashitpro
          Syntax for dos2unix is something like below

          dos2unix <filename>

          It has no source-destination issue.
          you supply one file and it will be converted thats it.
          You can use dos2unix as-

          $ find . -type f -exec dos2unix {} \;

          It will work recursively
          But make sure that your files are text files.
          because this command may corrupt your binaries.
          The first option is working only if we provide source and target filename both. I tried it as you said but with single argument that didnt worked. Also the second option is never terminating.

          Comment

          • ashitpro
            Recognized Expert Contributor
            • Aug 2007
            • 542

            #6
            Originally posted by rajarora
            The first option is working only if we provide source and target filename both. I tried it as you said but with single argument that didnt worked. Also the second option is never terminating.
            Hmm

            I think dos2unix works on solaris with different way..
            any way
            try this one.

            find . -type f -print | xargs -I {} dos2unix -ascii {} {}

            remember after find there is DOT(.)
            let me know if it works

            Comment

            • rajarora
              New Member
              • Sep 2007
              • 33

              #7
              Originally posted by ashitpro
              Hmm

              I think dos2unix works on solaris with different way..
              any way
              try this one.

              find . -type f -print | xargs -I {} dos2unix -ascii {} {}

              remember after find there is DOT(.)
              let me know if it works
              Thanks. It worked for me. I really appreciate your efforts and heartly thankful to you for solving my problem and also to thescripts.com forums. It really works!!!!

              One question I would like to ask is the mechanism behind this. I know the find command but I am tring to under stand this whole command.

              Regards,
              Raj Kumar Arora

              Comment

              Working...