PHP and command line (for Wiki)

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

    PHP and command line (for Wiki)

    Hi... I started to "program" in PHP (better say to read it :P) from a
    few days because I am installing a Wiki on a virtual server (Windows
    Server 2003 with Plesk 7.6). I have PHP5 and all is working just fine.

    However, I am trying to parse latex equations and encountered some
    troubles. I have already installed all the necessary software and when
    I execute the following by command line:

    C:\miktex\bin\l atex.exe --output-directory=C:\In etpub\vhosts\my site.com
    \httpdocs\wiki\ images\\tmp\\ --interaction=non stopmode C:\a.tex

    I generate the right file in the right folder. However, when I try to
    execute (adding it to a PHP routine that is executed for sure):

    $command = "C:\miktex\bin\ latex.exe --output-directory=C:\In etpub
    \vhosts\mysite. com\httpdocs\wi ki\images\\tmp\ \ --
    interaction=non stopmode C:\a.tex";
    $text = exec($command);

    it doesn't happen anything. Permissions in tmp should be fine... do
    you have any suggestion?

    Thanks
    Ale

  • gosha bine

    #2
    Re: PHP and command line (for Wiki)

    Ale wrote:
    Hi... I started to "program" in PHP (better say to read it :P) from a
    few days because I am installing a Wiki on a virtual server (Windows
    Server 2003 with Plesk 7.6). I have PHP5 and all is working just fine.
    >
    However, I am trying to parse latex equations and encountered some
    troubles. I have already installed all the necessary software and when
    I execute the following by command line:
    >
    C:\miktex\bin\l atex.exe --output-directory=C:\In etpub\vhosts\my site.com
    \httpdocs\wiki\ images\\tmp\\ --interaction=non stopmode C:\a.tex
    >
    I generate the right file in the right folder. However, when I try to
    execute (adding it to a PHP routine that is executed for sure):
    >
    $command = "C:\miktex\bin\ latex.exe --output-directory=C:\In etpub
    \vhosts\mysite. com\httpdocs\wi ki\images\\tmp\ \ --
    interaction=non stopmode C:\a.tex";
    $text = exec($command);
    >
    it doesn't happen anything. Permissions in tmp should be fine... do
    you have any suggestion?
    >
    Thanks
    Ale
    >
    Add 2>&1 to your command and look what it says (make use of exec's
    second param)


    --
    gosha bine

    extended php parser ~ http://code.google.com/p/pihipi
    blok ~ http://www.tagarga.com/blok

    Comment

    • Ale

      #3
      Re: PHP and command line (for Wiki)

      Hi - I simplified the code at the maximum and wrote:

      <?php

      $fp = fopen(".\f.tex" ,"a+");
      fputs($fp,'s_1' );
      fclose($fp);
      echo exec('2>&1; latex .\a.tex');

      ?>

      f.tex is written in the same folder where the PHP page is executed,
      showing that I have the proper permissions on the folder. When I
      execute

      latex .\a.tex

      from shell, where a.tex is a properly formatted latex source, all work
      fine.
      However, "echo exec('2>&1; latex .\a.tex'); " does not provide the
      attended results, not giving any output file. It returns the message
      "operable program or batch file".

      I really have no idea what is wrong :(

      Cheers,
      Ale

      Comment

      • Jerry Stuckle

        #4
        Re: PHP and command line (for Wiki)

        Ale wrote:
        Hi... I started to "program" in PHP (better say to read it :P) from a
        few days because I am installing a Wiki on a virtual server (Windows
        Server 2003 with Plesk 7.6). I have PHP5 and all is working just fine.
        >
        However, I am trying to parse latex equations and encountered some
        troubles. I have already installed all the necessary software and when
        I execute the following by command line:
        >
        C:\miktex\bin\l atex.exe --output-directory=C:\In etpub\vhosts\my site.com
        \httpdocs\wiki\ images\\tmp\\ --interaction=non stopmode C:\a.tex
        >
        I generate the right file in the right folder. However, when I try to
        execute (adding it to a PHP routine that is executed for sure):
        >
        $command = "C:\miktex\bin\ latex.exe --output-directory=C:\In etpub
        \vhosts\mysite. com\httpdocs\wi ki\images\\tmp\ \ --
        interaction=non stopmode C:\a.tex";
        $text = exec($command);
        >
        it doesn't happen anything. Permissions in tmp should be fine... do
        you have any suggestion?
        >
        Thanks
        Ale
        >
        '\' is the PHP escape character. Either use '\\' instead, or use
        forward slashes ('/') instead.

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

        Comment

        • Ale

          #5
          Re: PHP and command line (for Wiki)

          On Jul 3, 12:37 am, Jerry Stuckle <jstuck...@attg lobal.netwrote:
          Ale wrote:
          Hi... I started to "program" in PHP (better say to read it :P) from a
          few days because I am installing a Wiki on a virtual server (Windows
          Server 2003 with Plesk 7.6). I have PHP5 and all is working just fine.
          >
          However, I am trying to parse latex equations and encountered some
          troubles. I have already installed all the necessary software and when
          I execute the following by command line:
          >
          C:\miktex\bin\l atex.exe --output-directory=C:\In etpub\vhosts\my site.com
          \httpdocs\wiki\ images\\tmp\\ --interaction=non stopmode C:\a.tex
          >
          I generate the right file in the right folder. However, when I try to
          execute (adding it to a PHP routine that is executed for sure):
          >
          $command = "C:\miktex\bin\ latex.exe --output-directory=C:\In etpub
          \vhosts\mysite. com\httpdocs\wi ki\images\\tmp\ \ --
          interaction=non stopmode C:\a.tex";
          $text = exec($command);
          >
          it doesn't happen anything. Permissions in tmp should be fine... do
          you have any suggestion?
          >
          Thanks
          Ale
          >
          '\' is the PHP escape character. Either use '\\' instead, or use
          forward slashes ('/') instead.
          >

          the fopen code was working also in with the back slash... however
          thanks for the suggestion. In any case, latex is still not compiling
          the files when called by PHP...

          Cheers

          Comment

          • Jerry Stuckle

            #6
            Re: PHP and command line (for Wiki)

            Ale wrote:
            Hi - I simplified the code at the maximum and wrote:
            >
            <?php
            >
            $fp = fopen(".\f.tex" ,"a+");
            fputs($fp,'s_1' );
            fclose($fp);
            echo exec('2>&1; latex .\a.tex');
            >
            ?>
            >
            f.tex is written in the same folder where the PHP page is executed,
            showing that I have the proper permissions on the folder. When I
            execute
            >
            latex .\a.tex
            >
            from shell, where a.tex is a properly formatted latex source, all work
            fine.
            However, "echo exec('2>&1; latex .\a.tex'); " does not provide the
            attended results, not giving any output file. It returns the message
            "operable program or batch file".
            >
            I really have no idea what is wrong :(
            >
            Cheers,
            Ale
            >
            Maybe your webserver user doesn't have the authority to execute your
            latex command.

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

            Comment

            • Ale

              #7
              Re: PHP and command line (for Wiki)

              unfortunately I checked and that is not the problem... both for
              cmd.exe and latex.exe.
              As a matter of fact I get this message "operable program or batch
              file" and not access denied as was happening before I solved this
              issue (I think)

              Ale wrote:
              Hi - I simplified the code at the maximum and wrote:
              >
              <?php
              >
              $fp = fopen(".\f.tex" ,"a+");
              fputs($fp,'s_1' );
              fclose($fp);
              echo exec('2>&1; latex .\a.tex');
              >
              ?>
              >
              f.tex is written in the same folder where the PHP page is executed,
              showing that I have the proper permissions on the folder. When I
              execute
              >
              latex .\a.tex
              >
              from shell, where a.tex is a properly formatted latex source, all work
              fine.
              However, "echo exec('2>&1; latex .\a.tex'); " does not provide the
              attended results, not giving any output file. It returns the message
              "operable program or batch file".
              >
              I really have no idea what is wrong :(
              >
              Cheers,
              Ale
              >
              Maybe your webserver user doesn't have the authority to execute your
              latex command.
              >
              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstuck...@attgl obal.net
              =============== ===- Hide quoted text -
              >
              - Show quoted text -

              Comment

              • Jerry Stuckle

                #8
                Re: PHP and command line (for Wiki)

                Ale wrote:
                unfortunately I checked and that is not the problem... both for
                cmd.exe and latex.exe.
                As a matter of fact I get this message "operable program or batch
                file" and not access denied as was happening before I solved this
                issue (I think)
                >
                >
                >Ale wrote:
                >>Hi - I simplified the code at the maximum and wrote:
                >><?php
                >> $fp = fopen(".\f.tex" ,"a+");
                >> fputs($fp,'s_1' );
                >> fclose($fp);
                >> echo exec('2>&1; latex .\a.tex');
                >>?>
                >>f.tex is written in the same folder where the PHP page is executed,
                >>showing that I have the proper permissions on the folder. When I
                >>execute
                >>latex .\a.tex
                >>from shell, where a.tex is a properly formatted latex source, all work
                >>fine.
                >>However, "echo exec('2>&1; latex .\a.tex'); " does not provide the
                >>attended results, not giving any output file. It returns the message
                >>"operable program or batch file".
                >>I really have no idea what is wrong :(
                >>Cheers,
                >>Ale
                >Maybe your webserver user doesn't have the authority to execute your
                >latex command.
                >>

                It sounds like it's trying to say something like "not an operable
                program or batch file". It can still occur if the directory is
                inaccessible.

                Check your security for the file and directory. Ensure your webserver
                user has read authority on the directory and read and execute on the file.

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

                Comment

                • gosha bine

                  #9
                  Re: PHP and command line (for Wiki)

                  On 03.07.2007 01:32 Ale wrote:
                  Hi - I simplified the code at the maximum and wrote:
                  >
                  <?php
                  >
                  $fp = fopen(".\f.tex" ,"a+");
                  fputs($fp,'s_1' );
                  fclose($fp);
                  echo exec('2>&1; latex .\a.tex');
                  >
                  ?>
                  >
                  f.tex is written in the same folder where the PHP page is executed,
                  showing that I have the proper permissions on the folder. When I
                  execute
                  >
                  latex .\a.tex
                  >
                  from shell, where a.tex is a properly formatted latex source, all work
                  fine.
                  However, "echo exec('2>&1; latex .\a.tex'); " does not provide the
                  attended results, not giving any output file. It returns the message
                  "operable program or batch file".
                  >
                  I really have no idea what is wrong :(
                  >
                  Cheers,
                  Ale
                  >
                  2>& goes after command, not before it:

                  exec('latex .\a.tex 2>&1', $output);
                  print_r($output );


                  --
                  gosha bine

                  extended php parser ~ http://code.google.com/p/pihipi
                  blok ~ http://www.tagarga.com/blok

                  Comment

                  • Ale

                    #10
                    Re: PHP and command line (for Wiki)

                    Hi... er.... thank you for insisting on that line! :)

                    I checked all permission and where ok... at least on the latex.exe
                    file, while I had to manage adequately the access to the parent
                    folder. Not the simple code is working and I think I will be able to
                    build the rest of the php code on the top of that.

                    THANKS

                    Ale

                    Comment

                    Working...