Newline in the shell

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joe

    #1

    Newline in the shell

    I have just written my first php script that runs as a shell script. I
    run it using CLI that comes with my Win32 distro of php (4.3.4).
    Everything’s works nicely accept for one thing: ‘\n’ doesn’t work in my
    echo statements. So in practices:

    echo "hello\nwor ld"; becomes helloworld and not
    hello
    world

    I have a suspicion that it has something to do with windows using a
    different kind of new line syntax than Unix, but I can’t remember/find
    an example of how it should be done.

    In case this is the problem, what is the proper syntax, and if not what
    is the problem then?

    Joe
  • oeb -=- bleh bleh bleh

    #2
    Re: Newline in the shell


    "Joe" <amplifymysoul@ hotmail.com> wrote in message
    news:40bc6d61$0 $257$edfadb0f@d read12.news.tel e.dk...[color=blue]
    > I have just written my first php script that runs as a shell script. I
    > run it using CLI that comes with my Win32 distro of php (4.3.4).
    > Everything’s works nicely accept for one thing: ‘\n’ doesn’t work in my
    > echo statements. So in practices:
    >
    > echo "hello\nwor ld"; becomes helloworld and not
    > hello
    > world
    >
    > I have a suspicion that it has something to do with windows using a
    > different kind of new line syntax than Unix, but I can’t remember/find
    > an example of how it should be done.
    >
    > In case this is the problem, what is the proper syntax, and if not what
    > is the problem then?
    >
    > Joe[/color]

    \r\n maybe, or the other way around =P Cant Remember which.


    Comment

    • Alvaro G Vicario

      #3
      Re: Newline in the shell

      *** Joe wrote/escribió (Tue, 01 Jun 2004 13:49:49 +0200):[color=blue]
      > echo "hello\nwor ld";[/color]

      Works fine for me:

      #!/usr/bin/php

      <?
      echo "Hello\nWor ld"
      ?>


      [color=blue]
      > I have a suspicion that it has something to do with windows using a
      > different kind of new line syntax than Unix, but I can’t remember/find
      > an example of how it should be done.[/color]

      MacOS - \r
      Unix - \n
      Windows - \r\n


      --
      --
      -- Álvaro G. Vicario - Burgos, Spain
      --

      Comment

      • Nathan Gardiner

        #4
        Re: Newline in the shell


        "Joe" <amplifymysoul@ hotmail.com> wrote in message
        news:40bc6d61$0 $257$edfadb0f@d read12.news.tel e.dk...[color=blue]
        > I have just written my first php script that runs as a shell script. I
        > run it using CLI that comes with my Win32 distro of php (4.3.4).
        > Everything’s works nicely accept for one thing: ‘\n’ doesn’t work in my
        > echo statements. So in practices:
        >
        > echo "hello\nwor ld"; becomes helloworld and not
        > hello
        > world
        >
        > I have a suspicion that it has something to do with windows using a
        > different kind of new line syntax than Unix, but I can’t remember/find
        > an example of how it should be done.
        >
        > In case this is the problem, what is the proper syntax, and if not what
        > is the problem then?
        >
        > Joe[/color]

        Joe,

        Works fine on my system with PHP 4.3.6 win32.
        Not too sure what is causing this problem for you. I've never seen it
        before. Are you redirecting the output somewhere?


        Nathan



        Comment

        • Joe

          #5
          Re: Newline in the shell

          > Works fine on my system with PHP 4.3.6 win32.[color=blue]
          > Not too sure what is causing this problem for you. I've never seen it
          > before. Are you redirecting the output somewhere?
          >
          >
          > Nathan[/color]

          My mistake!

          echo "\n"; //works but
          echo '\n'; //dosn't

          Stupid mistake, sorry for the inconvenient

          Comment

          Working...