Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7937197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:27:42+00:00 2026-06-03T22:27:42+00:00

Okay this works with my linux server but I’m testing my web site at

  • 0

Okay this works with my linux server but I’m testing my web site at home on my PC and am trying to get php to execute my python script and of course the \ are WINDOWS only the path changes when Im on my linux machine.

$pyscript = 'C:\\wamp\\www\\testing\\scripts\\imageHandle.py';
$python = 'C:\\Python27\\python.exe';
$filePath = 'C:\\wamp\\www\\testing\\uploads\\thumbs\\10-05-2012-523.jpeg'


exec('$python $pyscript $filePath', $output, $return );

this works on my linux machine but not my windows testing server. How do I get this to run on windows? Oh and this also works when running directly from the command prompt in windows

EDIT:

This is the solution:

exec("$python $pyscript $filePath", $output);

I used single quotes instead of double quotes before, changing the single quotes to double quotes fixed the problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T22:27:44+00:00Added an answer on June 3, 2026 at 10:27 pm

    I find it odd that the filePath of C:\\wamp\\.... would work on a Linux machine.
    Anyway, have you tried NOT escaping the slashes?

    The issue can be related to several things, including OS specific methods of implementing the different program execution functions. I recommend just going through the different options, I always put the command into a single variable and then print out the variable so that I can see what I am about to run, if you saw two slashes, then you might know that there is no need to try to escape the slashes, however without printing it to the screen you wouldn’t know.

    Try going through the other process execution functions to see what works for you.
    http://www.php.net/manual/en/ref.exec.php

    The one that I have found works MOST like running it at the command line, is the backtick operator, and then next is system

    try something like this.

    $pyscript = 'C:\\wamp\\www\\testing\\scripts\\imageHandle.py';
    $python = 'C:\\Python27\\python.exe';
    $filePath = 'C:\\wamp\\www\\testing\\uploads\\thumbs\\10-05-2012-523.jpeg'
    
    $cmd = "$python $pyscript $filePath";
    echo $cmd;
    `$cmd`
    
    
    $pyscript = 'C:\wamp\www\testing\scripts\imageHandle.py';
    $python = 'C:\Python27\python.exe';
    $filePath = 'C:\wamp\www\testing\uploads\thumbs\10-05-2012-523.jpeg'
    
    $cmd = "$python $pyscript $filePath";
    echo $cmd;
    `$cmd` 
    

    EDIT: AHHH! I just figured it out, you are surrounding your command with single ticks ” which means the variable inside are not being replaced. Use double quotes instead. That WILL solve the problem, but I still recommend echoing the command out before you run it so that you would see the command you are running and you would be able to identify an issue like this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay I been trying to work this out but unable too. I have a
Okay, now this is more a rant about Linux than a question, but maybe
photoContainer below has children. This works okay, but if I click on any of
Okay this may be a simple question but I have yet to come with
Okay this is very hard to explain, but i want to add padding to
okay so this is probably a soft pitch question for sombody, but I want
My OS environment is linux. I have a php file in this folder -
Okay this is a real headscratcher. I have an application which calls a web
Okay this is similar to my last question but what I ended up doing
Okay, I stumbled upon this piece of code.. How come this works? What sort

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.