wierd error

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

    wierd error

    I have this very simple PHP script:

    #!/usr/local/bin/php -q

    <?php
    $post="From: \"Burek\" <burek@burek.hr >\\nSubject: foobar\\nNewsgr oups:
    hr.test\\n\\nNe sto, nesto.';

    $command="echo -ne \"mode reader\\npost\\ n" . $post . "\\n.\\nquit\\n \"
    | nc news.carnet.hr 119\n";
    echo $command;
    exec($command);
    ?>

    And it fails to execute:
    PHP Parse error: parse error in /home/users/n/nick/bin/postFAQ.php on
    line 6

    I have dissected the script and found that when I write it this way:
    $command=
    "echo"
    . " -ne \"mode reader\\npost\\ n" . $post . "\\n.\\nquit\\n \" | nc
    news.carnet.hr 119\n";
    Then the error is on the line where "echo" is. Now, what am I missing?

    --
    "Now the storm has passed over me
    I'm left to drift on a dead calm sea
    And watch her forever through the cracks in the beams
    Nailed across the doorways of the bedrooms of my dreams"
  • Syl

    #2
    Re: wierd error


    Nikola Skoric wrote:[color=blue]
    > I have this very simple PHP script:
    >
    > #!/usr/local/bin/php -q
    >
    > <?php
    > $post="From: \"Burek\" <burek@burek.hr >\\nSubject: foobar\\nNewsgr oups:
    > hr.test\\n\\nNe sto, nesto.';
    >
    > $command="echo -ne \"mode reader\\npost\\ n" . $post . "\\n.\\nquit\\n \"
    > | nc news.carnet.hr 119\n";
    > echo $command;
    > exec($command);
    > ?>
    >
    > And it fails to execute:
    > PHP Parse error: parse error in /home/users/n/nick/bin/postFAQ.php on
    > line 6
    >
    > I have dissected the script and found that when I write it this way:
    > $command=
    > "echo"
    > . " -ne \"mode reader\\npost\\ n" . $post . "\\n.\\nquit\\n \" | nc
    > news.carnet.hr 119\n";
    > Then the error is on the line where "echo" is. Now, what am I missing?[/color]

    try this :

    $command="echo -ne 'mode reader\\npost\\ n' . $post . '\\n\\nquit\\n\ '
    | nc news.carnet.hr 119\n";


    also - why do you the dot operator here :
    "\\n.\\nquit\\n \"

    Comment

    • Nikola Skoric

      #3
      Re: wierd error

      Dana 5 Jun 2006 19:14:07 -0700,
      Syl <david.hunter@g mail.com> kaze:[color=blue]
      > try this :
      >
      > $command="echo -ne 'mode reader\\npost\\ n' . $post . '\\n\\nquit\\n\ '
      >| nc news.carnet.hr 119\n";[/color]

      Well, that won't work. The code I put in $comand variable is not PHP code
      but bash code.
      [color=blue]
      > also - why do you the dot operator here :
      > "\\n.\\nquit\\n \"[/color]

      That's not dot operator but NNTP command signalising end of article...

      --
      "Now the storm has passed over me
      I'm left to drift on a dead calm sea
      And watch her forever through the cracks in the beams
      Nailed across the doorways of the bedrooms of my dreams"

      Comment

      • Jerry Stuckle

        #4
        Re: wierd error

        Nikola Skoric wrote:[color=blue]
        > I have this very simple PHP script:
        >
        > #!/usr/local/bin/php -q
        >
        > <?php
        > $post="From: \"Burek\" <burek@burek.hr >\\nSubject: foobar\\nNewsgr oups:
        > hr.test\\n\\nNe sto, nesto.';
        >
        > $command="echo -ne \"mode reader\\npost\\ n" . $post . "\\n.\\nquit\\n \"
        > | nc news.carnet.hr 119\n";
        > echo $command;
        > exec($command);
        > ?>
        >
        > And it fails to execute:
        > PHP Parse error: parse error in /home/users/n/nick/bin/postFAQ.php on
        > line 6
        >
        > I have dissected the script and found that when I write it this way:
        > $command=
        > "echo"
        > . " -ne \"mode reader\\npost\\ n" . $post . "\\n.\\nquit\\n \" | nc
        > news.carnet.hr 119\n";
        > Then the error is on the line where "echo" is. Now, what am I missing?
        >[/color]

        Nikola,

        Check your file to see if you possibly have mismatched double quotes earlier in
        your file (or in a file which includes this one).

        Normally when I see this it means I've screwed up and had mismatched quotes
        earlier in the file.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • Nikola Skoric

          #5
          Re: wierd error

          Dana Tue, 06 Jun 2006 07:02:33 -0400,
          Jerry Stuckle <jstucklex@attg lobal.net> kaze:[color=blue]
          > Check your file to see if you possibly have mismatched double quotes earlier in
          > your file (or in a file which includes this one).
          >
          > Normally when I see this it means I've screwed up and had mismatched quotes
          > earlier in the file.[/color]

          Nope, I pasted the whole script, and the script is executed from command
          line, it is not included...

          --
          "Now the storm has passed over me
          I'm left to drift on a dead calm sea
          And watch her forever through the cracks in the beams
          Nailed across the doorways of the bedrooms of my dreams"

          Comment

          • Jerry Stuckle

            #6
            Re: wierd error

            Nikola Skoric wrote:[color=blue]
            > I have this very simple PHP script:
            >
            > #!/usr/local/bin/php -q
            >
            > <?php
            > $post="From: \"Burek\" <burek@burek.hr >\\nSubject: foobar\\nNewsgr oups:
            > hr.test\\n\\nNe sto, nesto.';
            >
            > $command="echo -ne \"mode reader\\npost\\ n" . $post . "\\n.\\nquit\\n \"
            > | nc news.carnet.hr 119\n";
            > echo $command;
            > exec($command);
            > ?>
            >
            > And it fails to execute:
            > PHP Parse error: parse error in /home/users/n/nick/bin/postFAQ.php on
            > line 6
            >
            > I have dissected the script and found that when I write it this way:
            > $command=
            > "echo"
            > . " -ne \"mode reader\\npost\\ n" . $post . "\\n.\\nquit\\n \" | nc
            > news.carnet.hr 119\n";
            > Then the error is on the line where "echo" is. Now, what am I missing?
            >[/color]

            OK, check your first line. You start the string with a " but end it with a '.

            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstucklex@attgl obal.net
            =============== ===

            Comment

            • Nikola Skoric

              #7
              Re: wierd error

              In article <k6CdnbVIiJJpfh jZnZ2dnUVZ_oGdn Z2d@comcast.com >,
              jstucklex@attgl obal.net says...[color=blue]
              > OK, check your first line. You start the string with a " but end it with a '.[/color]

              I refuse to belive this... but, yes, you are right. A week of debugging
              one single quote. Hope it won't happen again. Thanks a bunch.

              --
              "Now the storm has passed over me
              I'm left to drift on a dead calm sea
              And watch her forever through the cracks in the beams
              Nailed across the doorways of the bedrooms of my dreams"

              Comment

              • Rik

                #8
                Re: wierd error

                Nikola Skoric wrote:[color=blue]
                > In article <k6CdnbVIiJJpfh jZnZ2dnUVZ_oGdn Z2d@comcast.com >,
                > jstucklex@attgl obal.net says...[color=green]
                >> OK, check your first line. You start the string with a " but end it
                >> with a '.[/color]
                >
                > I refuse to belive this... but, yes, you are right. A week of
                > debugging
                > one single quote. Hope it won't happen again. Thanks a bunch.[/color]

                Many editors with syntax highlighting could have shown you this in a
                heartbeat. Which editor do you use?

                Grtz,
                --
                Rik Wasmus


                Comment

                Working...