I am trying to execute a command from php script using php exe function.
The script calls .exe file located in program files whereas my xampp is intalled in E:
I m trying the following command C:\\Program Files\\GPStill\\pstill.exe its not working.But if i manually open cmd prompt and stand in c:\prgram files folder than run pstill.exe it works...
Any ideas ???
you need to escape the folders for example
<?php
$command 'C:\"Program Files"\"Internet Explorer"\iexplore.exe';
exec($command);
?>
Related
I'm trying to generate a pdf from a latex file with the command exec but it doesn't seem to recognize "xelatex".
When I echo any other command like "ls" with exec it works.
Also, the file is generated when I run the command from cmd.
Any idea what the problem might be ?
I'm working on windows10.
Thanks,
I have installed xampp in my windows OS.completed the configuration settings .But i can't run a simple php script from CMD . Is there anything should i do bfore running the script .
Be sure, that php is added to your path variable, so you can run php -v in your terminal. You should get the current version of your installed php.
If php was added to your path variable, you can run a php script like php file.php
See http://php.net/manual/en/faq.installation.php#faq.installation.addtopath
First, you have to go till that file path in command prompt then use command to execute php script,
php file_name.php
Using PHP's system/exec commands to run a script that in-turn makes an executable run, that executable when run directly via terminal generates 2 text files successfully but fails to do so when it is made to run using command in php, which is:
system("bash run.sh");
this run.sh contains command which executes an executable. contents of run.sh are:
#!/bin/bash
./op 2
where op is an executable file, which successfully creates two text files only when run using a terminal.
I am trying to run a php file from shell script file or terminal in open-wrt platform. I have executed php files in crontab and those are running perfectly. i need to run a php file without putting it into crontab.I am trying it with the following command
chmod 777 /www/api/*
cd /www/api
php myphp.php
but it showing -ash: php: not found
I have also try it putting the following command on top of the script
#!/usr/bin/php
but it is not working. i could not figure out the problem!!!
You must install php-cli package, after you can run the script by
php-cli script.php
I have 1 file php: C:\\Xml2InDesign\\InDesignTagConverter.php
I exe it by:
$sjis_cmd="php \"C:\\Xml2InDesign\\InDesignTagConverter.php\";
exec($sjis_cmd, $output);
It not working. What do i must setting?
I run from cmd:
php "C:\Xml2InDesign\InDesignTagConverter.php" "c:\work\link2\\tmp\\5699\\direction.xml" "c:\work\link2\\tmp\\5699\\tables"
Show error: 'php' is not recognized...
Find your php.exe path and run command from there.
Like if your php.exe is in C:\PHP5\php.exe , then you can execute like this
C:\PHP5\php.exe "C:\\Xml2InDesign\\InDesignTagConverter.php\"
Refer this link
OR
if you want to run it through php code then use exec command
The PHP CLI as its called ( php for the Command Line Interface ) is called php.exe It lives in c:\wamp\bin\php\php5.x.y\php.exe ( where x and y are the version numbers of php that you have installed )
If you want to create php scrips to run from the command line that great its easy and very useful.
Create yourself a batch file like this, lets call it phppath.cmd :
PATH=%PATH%;c:\wamp\bin\php\php5.x.y php -v
Save this into one of your folders that is already on your PATH, so you can run it from anywhere.
Now from a command window, cd into your source folder and run >phppath.
Then run
php your_script.php