Am using windows server for running website. My application is running in linux server. I want to call the application with parameters(inputs) from website using php. The application accepts some inputs and returns output. I want to display the output in website. Please some one help me by giving idea or scripts. Thanks in advance.
From your simplistic description, you might be able to use this on the windows webserver to invoke the application part residing on the linux server:
<?php
readfile("http://otherserver.com/app.php?input=123");
?>
If the inputs are expected via POST, then you'll have to utilize cURL instead. (Which you'd have to do in case of a disabled allow_url_fopen anyway.)
You can use WinExe in your Linux system and execute command from your PHP to remotely call command lines on your Windows system
Related
I'm new to web development. I'm trying to execute a shell script using PHP's shell_exec(). Inside the script, I'm trying to invoke a GUI application(Qt). When I executed the PHP script from a terminal the application started as expected. But when I opened it from browser an empty blank page appeared.
I'm using Ubuntu with apache2 server running as service. When I searched in google, the similar problem is solved in the Windows environment by allowing apache service to interact with the desktop.
PHP Script:
<?php
$log = shell_exec('sh testcmd.sh');
?>
testcmd.sh:
./Program1
Any help provided will be highly appreciated.
It is somewhat unclear what you're asking.
If you wish that browsing to a certain web site will run a PHP script that will open a GUI app for the client to interact with, the answer is "you can't". The reason is that the way the setup works is that the server and the client run on different machines, and your PHP runs on the server machine. As such, the client never gets to see the running program.
The above is true also for Windows. The answer you quote in your question does not apply to a server running on a different machine than the client.
If, for whatever reason, you want something that works only when the server and client run on the same machine (or there is someone watching the server's display), then you need to do the equivalent of the Windows answer.
The graphics display on Linux (assuming you're not running wayland) is using a protocol called X11. In order for the display to appear, your GUI program needs two things. The first is to know which display it needs to use. This is supplied with an environment variable called DISPLAY. The second is an authorization to actually use that display.
So in order for your PHP script to run a GUI app that will show its GUI, you will need to first do the following steps:
Set the DISPLAY variable to the correct value (copy from your desktop environment).
Run xauth add something, where you can get what something is by running xauth list on your desktop environment.
If you do these two things (in this order), your GUI should show up.
I am studying on YouTube HTML5 forms with PHP files; the videos either start with a web page containing the form and link to a PHP file or they put everything in php files; I copy the instructors exact files; but they do not work: nothing is posted after filling the form and hitting the submit button.
I have had the files on a USB flash drive then tried them actually on the computer: nothing.
My question is then: "Do I need to have an actual server on my computer in order for PHP files to function?"
Yes. PHP requires a web server to run on.
You can run it on your own computer; the web server doesn't have to be connected to the internet while you are creating and testing your PHP scripts off your local machine. You can read more about this on the official PHP What do I need page
You can download one of the following local servers:
Windows: WAMP
OSX: MAMP
Linux: LAMP
XAMPP is also an option, it's cross-platform (as referenced by ATechGuy)
Here is a good explanation of Why a web server is required to run PHP. Basically it is because PHP is a dynamic server-side scripting language.
However if you just want to run simple PHP scripts, with no web pages. This is possible without a web server running. See this question: How can I run a php without a web server?
Yes, PHP will need to run on a server in order to execute. If you have a Mac, it should be equipped to run an Apache server. I found this article to be really helpful when developing with PHP - https://jason.pureconcepts.net/2015/10/install-apache-php-mysql-mac-os-x-el-capitan/
Yes. PHP files contain code that must be handled by an interpreter, that is, a program that reads the PHP code and outputs accordingly. This can be done without a webserver (using command line php) but PHP is most commonly used with a web server.
You want to setup some sort of stack with a web server and php. A lot of beginners use apache as a web server, and since you are comfortable using youtube for learning, a simple search for "apache php" and your operating system.
I have two html forms and two php scripts. The first one is a form which is supposed to submit a users email to a .txt file, and the other is a Stripe payment form which uses php code to charge the customer.
Now my problem is that there are some issues with the two php scripts, that I can't figure out how to fix, because I am not really sure how to test the scripts. Normally when testing the html scripts I would just open the html files in my browser, but that doesn't work on my php scripts as the site just shows what is written in the scripts when called/submitted.
So my question is how do I test my scripts, without having to use a hosting account and can I even test it like this?
You need to run a web server on your local computer to test it out. I would suggest looking into something called Vagrant, which allows you to fairly easily create virtual machines on your computer in which you can install anything you like without fear of messing up anything else. If you go here you can even find a "box" to create a virtual machine that already has apache and php installed.
Depending on your version of PHP there's a webserver builtin right into PHP:
http://php.net/manual/en/features.commandline.webserver.php
You probably have to install a web server locally with php enabled. Since php is a server side language it needs a server to run on, in order to send you back the html, after execution. If you need to see the result on a browser.
http://en.wikipedia.org/wiki/LAMP_%28software_bundle%29.
Or run your script from terminal (you must have php installed) if you don't need to see the result in the browser and just want to run your script.
$ php myscript.php
I have created a HTTP Server on Marklogic to run my application. Now my application has a xqy page. Form that xqy page I want to call a page which is written in PHP. How can I execute PHP page from Marklogic? I have also installed Wamp Server for PHP on my machine. From within the Wamp server that PHP code executes but I want to run that php script from my application which is hosted on Marklogic.
Make an http request via xdmp:http-request().
I think Eric must mean xdmp:http-get().
Currently I have a website on my local computer that uses PHP to make a call to a .jar program. It works fine when I run it on my local machine.
When I upload it to my host and try to run the same .jar file, I get no output...
Do you know why this is? Do I have to change the PHP.ini on my remote host to allow jars to be executable or something?
Any help is appreciated.
Thanks Phil
EDIT:
Code snippet:
shell_exec("java -jar news.jar get phil")
get and phil being two parameters to the news.jar program. I am using windows XP on my local machine, and I just have simple PHP MySQL hosting online. Does hosting such as this not support shell_exec() calls?
Code snippet: shell_exec("java -jar news.jar get phil")
It is extremely probable that this won't work out of the box on shared hosting, either because shell_exec() is disabled altogether, or executing java is not available to your shared hosting package, or the Java VM executing the jar doesn't have the rights to do what the jar wants to do.
You should be able to at least find out whether you can execute Java at all by using exec instead of shell_execute, giving it $output and &$return_var variables (see the linked manual page) and seeing what they contain after the call.
The best thing, though, would be talking to the provider and asking what is possible, and what isn't.