I am looking into using Selenium RC with PHP but so far, all examples require that you use the terminal to run the php script. Isn't it possible to just run the php file and selenium code without access to terminal?
It is possible, as long as the PHP program is allowed to make remote HTTP requests to the Selenium RC.
But you might need to adjust the maximum execution time if needed:
Reference: http://www.linuxask.com/questions/set-the-maximum-execution-time-in-php
Related
I'm trying to open a Windows program from PHP using exec() on a local machine. Is it possible to start a system program (on Windows 10 if it's relevant) that runs in the foreground using PHPs exec function?
This line:
exec("C:/Windows/notepad.exe 2>&1");
Causes Microsoft's Notepad to open in the background (verified it is actually running using task manager) but I have no access to it, i.e., it doesn't open a window. How do I get it to run in the foreground so I can actually see it and interact with it?
So this seems like an utter ball ache to achieve using exec() for your average coder. There's another way to achieve this result: Have PHP generate .bat files using file_put_contents() with instructions to open a given file path and then auto-delete itself, like so:
#echo off
Start "" "C:\Path\To\File\SomeFile.txt"
del %0
This method requires some kind of task scheduler to monitor a given folder and execute the batch files as they come in. I believe PowerShell can do this, and possibly the Windows Task Scheduler. I think Linux has Cron.
I'm writing an elixir application that needs to communicate with several APIs.
One api is a connection to Post Affiliate Pro which uses PHP and has a PHP class file you can download to use their API easily.
As I seach for answer online my results are overwhelmed about using PHP to run elixir which is the opposite of wha. I need
I know nothing about PHP, I don't even know what dependencies I'll need on the server to run a php script.
My elixir program currently runs an executable using System.cmd().
Would it be possible to use System.cmd() to run the script file and have the output of the PHP script be routed to elixir's STDIN? I've never done that before but maybe I should start there? Any suggestions?
If its a script designed to be run from the command line, the you should be able to run it with System.cmd/1. First try to run the script manually from the command line and get it working.
I would start with ensuring that you have php installed on your system. If not, you will need to install it.
The other option is to use the php script to understand the API its using and create your own in Elixir, using a http client.
I have modules written in python. And I am running my webserver through php apache server. For invoking the existing python scripts, I'm using the following command and this works fine,
shell_exec("python.exe file.py args");
Is there a proper way apart fro doing shell_exec / exec comnand from php.
There are two ways to do that.
Integrate Python into PHP. PHP supports C extensions while Python has libpython. I do not know if such extension exists. This approach doesn't require additional processes to start, but it is total madness.
Run Python script as a service and instead of shell_exec() call some REST API (or whatever). This approach requires additional entities such as services, sockets, but it seem to be architecturally correct.
I have 55 php files that I would like to run simultaneously from the command line. Right now, I am running them in multiple CLI windows using the code:
php Script1.php
I would like to be able to call one single php file that would execute all 55 php files simultaneously. I have been reading about how to make the command line not wait for the output, but I can't seem to make it work.
This thread:
How to run multiple PHP scripts from CLI
suggests putting an & at the end of the command to run the command in the background, but using the xampp CLI this doesn't seem to do anything.
Any ideas greatly appreciated.
Brian
By mentioning XAMPP, I assume you are on windows. I think what you need is the start command. You probably need start php Script1.php. For more info, do a
start /?|more
Linux
Apart from adding a &, you also need to redirect output to somewhere - otherwise your php process waits until the other process finished, because there could be more output:
exec('/path/to/program & > /dev/null 2>&1')
You could use the php forking mechanism. Read about it here: http://php.net/manual/en/function.pcntl-fork.php
I have a (possibly dumb) question.
I have a script made in php, constructed for cli usage. Works fine when I run it from the command line, no problem there. The problem is that the site I'm working on has ssh restrictions on the hosting server and I cannot ssh there to run it. Hence my question: how can I run the script from another php that is web-accessible? Already tried with exec(), system(), etc.
The main problem is that I need he $_SERVER['SHELL'] variable set, and when the call is comming from a web browser of course php doesn't set it.
Any ideeas will be greatly apreciated, thanx.
There are many possibilities why exec() and related function calls are not working for you.
Your webhost does not have PHP-CLI installed. Just a webserver module
You need to use the full path to the php binary for lack of a decent shell environment. E.g. /usr/bin/php <script> instead of php <script>.
Your webhost has installed PHP-CLI on a non-standard path (e.g. /usr/local/bin/php, or /opt/php5/php)
The webserver user does not have rights to access the php binary
Et cetera..
maybe update the php script to be both an include and a cli script.
use
__FILE__
to check if it's a file, then read the params. otherwise do nothing.
and as an include just call the function you want directly.