13 Replies Latest reply: Mar 4, 2013 6:34 AM by Billy~Verreynne RSS

    File transfer from windows to unix

    992876
      I am writing to a text file under the windows environment and I am using chr(10) for new line. However when viewing the same text file under UNIX a square character was replacing the char(10). why? thanks. I just want to create a new line here.

      Edited by: 989873 on Mar 3, 2013 10:23 PM

      Edited by: 989873 on Mar 3, 2013 10:24 PM
        • 1. Re: File transfer from windows to unix
          sb92075
          989873 wrote:
          I am writing to a text file under the windows environment and I am using chr(10) for new line. However when viewing the same text file under UNIX a square character was replacing the char(10). why? thanks. I just want to create a new line here.

          Edited by: 989873 on Mar 3, 2013 10:23 PM

          Edited by: 989873 on Mar 3, 2013 10:24 PM
          Windows uses CHR(10) & CHR(13) to separate records in text file.
          • 2. Re: File transfer from windows to unix
            992876
            how about in unix
            • 3. Re: File transfer from windows to unix
              Manik
              I think they are control M in unix .. search in google for removing ^M characters.

              Cheers,
              Manik.
              • 4. Re: File transfer from windows to unix
                jeneesh
                How are you writing into file?
                How are you transferring the file from Windows to UNIX?

                Note that, New line characters are different in Windows and Unix..

                In Window it is - Carriage Return + Line Feed (13 and 10)
                In Linux it is - Line Feed

                If the file is opening properly in a text editor in Windows - you could think of transferring the file in ASCII mode..
                • 5. Re: File transfer from windows to unix
                  992876
                  yes. i am at a windows environment and was transfer the file to UNIX. how would i turn the ascii mode on?


                  UTL_FILE.PUT_LINE(v_file, 'text1' || chr(10) || 'text2');

                  should output:
                  text1
                  text2
                  • 6. Re: File transfer from windows to unix
                    Billy~Verreynne
                    989873 wrote:
                    yes. i am at a windows environment and was transfer the file to UNIX. how would i turn the ascii mode on?
                    ASCII/Binary modes are used by FTP. ASCII mode changes CR/LF character combinations from the source platform, to whatever is supported by the destination plaform.
                    UTL_FILE.PUT_LINE(v_file, 'text1' || chr(10) || 'text2');

                    should output:
                    text1
                    text2
                    Correct. This is what will output on Unix/Linux. But as you specified put_line() and not just put(), another (system generated) CR/LF will follow after 'text2'.
                    • 7. Re: File transfer from windows to unix
                      _Karthick_
                      989873 wrote:
                      yes. i am at a windows environment and was transfer the file to UNIX. how would i turn the ascii mode on?


                      UTL_FILE.PUT_LINE(v_file, 'text1' || chr(10) || 'text2');

                      should output:
                      text1
                      text2
                      You are using PUT_LINE, this will automatically add OS specific line terminator at the end of the line. In your case the OS is WINDOWS and so it will be adding CHR(13) + CHR(10).

                      So to avoid this you need to use the PUT function and have your own line terminater added.

                      Some thing like this
                      UTL_FILE.PUT(v_file, 'text1' || chr(10) || 'text2' || chr(10));
                      • 8. Re: File transfer from windows to unix
                        992876
                        I am using filezilla to view the file through notepad. however the result is still 'text1text2'.


                        I use below command:
                        UTL_FILE.PUT(v_file, 'text1' || chr(10) || 'text2' || chr(10));
                        • 9. Re: File transfer from windows to unix
                          _Karthick_
                          989873 wrote:
                          I am using filezilla to view the file through notepad. however the result is still 'text1text2'.


                          I use below command:
                          UTL_FILE.PUT(v_file, 'text1' || chr(10) || 'text2' || chr(10));
                          Login to UNIX using a command line utility (I use F Secure-SSH) and just CAT the file.
                          • 10. Re: File transfer from windows to unix
                            992876
                            thanks

                            Edited by: 989873 on Mar 3, 2013 11:34 PM
                            • 11. Re: File transfer from windows to unix
                              Billy~Verreynne
                              989873 wrote:
                              I am using filezilla to view the file through notepad. however the result is still 'text1text2'.
                              Notepad (on Windows), and some other older Windows-based text editors, do not show Unix linefeeds. So again - what you see is correct as that is typically what a Windows plain text editor, not supporting Unix linefeeds, will show.

                              However with a Unix plain text editor, the file will show 2 separate lines of text.
                              • 12. Re: File transfer from windows to unix
                                992876
                                i use wordpad and the result is:
                                text1
                                text2

                                however in notepad:
                                text1text2.

                                my concern is, I am using that file to a stored procedure that send email with attachment.. and recipients might use notepad for viewing,

                                Edited by: 989873 on Mar 4, 2013 1:00 AM
                                • 13. Re: File transfer from windows to unix
                                  Billy~Verreynne
                                  989873 wrote:
                                  i use wordpad and the result is:
                                  text1
                                  text2

                                  however in notepad:
                                  text1text2.

                                  my concern is, I am using that file to a stored procedure that send email with attachment.. and recipients might use notepad for viewing,
                                  If you send the data in the correct format, why be concerned whether or not the end-user uses the correct application to view that data? That is surely the end-user's responsibility to use the correct s/w to view the data?

                                  Else you are saying that you are using the wrong format - in which case you need to use the correct format (e.g. DOS linefeed and not Unix linefeeds).