Find the answer to your Linux question:
Results 1 to 8 of 8
Hi, I have a script thats been custom made for Windows but i now have a Linux server and iv been told that i need to convert the windows newline ...
  1. #1
    Just Joined!
    Join Date
    Jul 2008
    Posts
    4

    Perl Script - Windows To Linux

    Hi,

    I have a script thats been custom made for Windows but i now have a Linux server and iv been told that i need to convert the windows newline to Unix. Iv read a topic on here about a FLIP Binary command that will do this so it will work as at the moment i get a 500 Internal Server Error which im guessing is because its not yet been converted.

    Can someone help me install the Flip command onto my server please and tell me where to get it.

    This is the thing im talking about http://www.linuxforums.org/forum/133996-post6.html

    Thanks

  2. #2
    Linux Engineer Thrillhouse's Avatar
    Join Date
    Jun 2006
    Location
    Arlington, VA, USA
    Posts
    1,377
    If it's just a matter of converting the Windows ^M characters to UNIX newline characters, you can use dos2unix, which I believe is much more prevalent than flip (I've never heard of flip before).

    What kind of UNIX are you using? Knowing that, we can help you install dos2unix (if it's not already installed) and get it to convert your script.

  3. #3
    Just Joined!
    Join Date
    Jul 2008
    Posts
    4
    Hi,

    I have CENTOS Enterprise 5.2 i686 on standard.

    I have tried Dos2Unix but nothing happens.

    Just found out its not ^M that needs converting as thats not in any of my .pl files.

    This is what he said the developer (doesnt do Linux, only Windows, thats why i need a little help):

    In Windows, the new line character is actually two characters, \n\r
    This is New Line then Return Feed so that the cursor moves back to start of the line on the next line down like a type writer
    Unix just uses \n
    Windows \n\
    You need to ask someone who understands UNIX. Take a look at athis to understand it
    ASCII text converstion between UNIX, Macintosh, MS-DOS
    There is no point asking me, as I dont understand or work with Unix. All I know is that the file formats are different and need converting. How they are converted or what happens i have no idea. Thats why u need to ask someone who understands Unix
    If it were windows, I would have no problem

  4. #4
    Linux Engineer Thrillhouse's Avatar
    Join Date
    Jun 2006
    Location
    Arlington, VA, USA
    Posts
    1,377
    Have you tried using the flip binary that's on the site you linked to? I don't have a Linux machine available to test it on right now.

  5. #5
    Just Joined!
    Join Date
    Jul 2008
    Posts
    4
    i dont know how to install it thats the thing

    Was hoping someone could maybe help me?

  6. #6
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Simple perl script to do it
    Code:
    #!/usr/bin/perl -pi.bak -w
    s/[^M^Z]*$//
    The ^M is a Ctrl-M, ^Z is Ctrl-Z. The script will save the original file with a .bak suffix.

  7. #7
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    Quote Originally Posted by Standup Media View Post
    I have tried Dos2Unix but nothing happens.
    i guess you are not using it correct
    Code:
    dos2unix file file

  8. #8
    Just Joined!
    Join Date
    Jul 2008
    Posts
    4
    Quote Originally Posted by scm View Post
    Simple perl script to do it
    Code:
    #!/usr/bin/perl -pi.bak -w
    s/[^M^Z]*$//
    The ^M is a Ctrl-M, ^Z is Ctrl-Z. The script will save the original file with a .bak suffix.
    i get Internal Server Error when i do that

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...