SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why wont my system call work?

    at the top of my PHP script is this:
    Code:
    $choice=$_POST['choice'];
    system('./goXML.py '.$choice.'.log');
    Now I have made sure that this thing at least runs... though I have no idea how to pass $_POST variables using the command line.

    The first thing I checked was whether the "goXML.py" line even works... and it does. Running in stand-alone mode, it makes a directory (if it doesnt exist - deletes & creates new if it does), and writes some XML docs to those folders, depending on the log I feed it as input. These XML docs then are used later in the script as input to a SWF.

    Second I checked if the PHP script was actually calling the Python script with the correct arguments. All I did to verify this was to append the Python script args to /etc/httpd/logs/error_log.

    Any ideas on how to fix my problem?

  2. #2
    SitePoint Zealot
    Join Date
    Oct 2007
    Location
    In the blogosphere
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might want to call the full path of the python script.
    bLueFrogX's Blog - Random Ramblings of a NEET Techie ★

  3. #3
    SitePoint Addict CVPer's Avatar
    Join Date
    Sep 2007
    Location
    Vancouver, BC, Canada
    Posts
    233
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    have you checked whether your php scripts successfully locate the py file?
    * @location Vancouver, BC, Canada
    * @name Steve
    * @job PHP/MySQL, Drupal, WordPress Developer

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bluefrogx View Post
    You might want to call the full path of the python script.
    Tried that, no difference.

    Quote Originally Posted by CVPer View Post
    have you checked whether your php scripts successfully locate the py file?
    The Python script has a line in it that opens the HTTPD error_log & appends:
    "PYTHON: Gained control of scripting... using arg[1]:/directory/passed/from/php/script"

    Which means that theoretically it worked... (and yes Im saying that I have verified this)

    My guess was actually permissions passing. Doesn't PHP run everything as "nobody"? Which would mean that my Python script could get hung up if it needed more permissions... Think about it this way... if every normal user could just write a script, and have the script execute "rm -rf /", we would all be struggling to find jobs.

    How do you go about checking whether code is using OS calls that require permissions? Is that even possible?

  5. #5
    SitePoint Addict CVPer's Avatar
    Join Date
    Sep 2007
    Location
    Vancouver, BC, Canada
    Posts
    233
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how did you run the py file?
    using
    python ./test.py params
    or just
    ./test.py params?
    * @location Vancouver, BC, Canada
    * @name Steve
    * @job PHP/MySQL, Drupal, WordPress Developer

  6. #6
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I figured it out.

    I appreciate the help, but apparently I am just stupid. I missed the fact that I was using the result of the system() call in a while loop... and I was thus perpetuating an infinite loop.

    Although it has the correct functionality when fed an inappropriate string, if it actually works correctly, it gets stuck in the infinite loop condition, and never gets to finish the execution of the system() call, thus never actually making files, etc...

    oops!

    Thanks for all the help anyway!


Bookmarks

Posting Permissions

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