i have server ubuntu . I want to show network traffic upload & download in php .
A command is in the terminal for monitoring traffic: enter link description here
How can I use command nload -mon php.
Like this :
i have no idia about it
The simplest solution is:
to call this function in PHP file via exec().
to parse the output from this function and prepare the markup to present those values (total input/output) on the page.
Better solutions depend on how often this info should be retrieved and how pretty it should be rendered in the browser.
It compiles php to apache and apache simply does not access network uses. There are several ways for this;
1-) shell_exec;
In ubuntu you can prepare a console command that will output the network data as json, then you can run this console command in ubuntu using shell_exec in php.
2-) third part programming;
For example, you can develop scripts on platforms such as python, node js, etc. and access network usage. Again, with the software you have developed, you can instantly print the network usages to the database. In another option, you can access network information with software such as phton and show them on socket, and you can get data from php with socket. Finally, you can develop an api for this on pyhton.
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'd like to "embed" a shell console on a website that allows full root access to the shell. This is in an environment where the server is wiped every 5 minutes. Is there a way to do this in PHP? I can provide the shell a user/pass as well.
There are plenty of web based shells written in PHP. They range from basic shells where you just input a command and hit submit, and get the output back, to sophisticated AJAX shells that let you run interactive terminal apps like IRC clients.
If you don't insist on the backend being PHP (the frontend can be), then shellinabox is a neat one.
I need a program to send and receive some text by a COM port. I would like to launch this by a exec command (command line).
I tried to view if Hyperterminal or putty can be used by command line but i can not find a solution.
This would be a workaround to send and receive text by a PHP webserver, I'm going to use the php exec function to run it.
I published two tiny command line applications called SerialSend and ComPrinter on my blog, which send and receive text via serial port. I'm not sure if they'll do exactly what you need since one only sends and the other only receives, but maybe you can get them to do what you want. They're completely free, you can download binary or sourcecode (they're really easy to compile), and they're both really easy to use.
Here are the links:
SerialSend web page
ComPrinter web page
I am getting daily data dump via e-mail, which is being processed by Access (based on the Outlook rule, VBA is extracting the attachment and running Access procedures, so I get a report).
As data dump is getting bigger and bigger, and having in mind that Access is run locally which consumes my resources, I want to set up a PHP/MySQL server to make it more efficient.
The first challenge I face is how to connect Outlook rule with PHP execution? (as I will have Outlook set up on the Windows based machine, with apache/mysql set up (WAMP))
Anyone can share some insights on how to start PHP execution from Outlook?
Thanks for the help!
Srdjan
If you have an existing setup using Access and VBA, and you just need a better database behind it, could you not just use MySQL without PHP and use the MySQL ODBC driver instead of the Access connection you are using at the moment (assuming you are currently using ODBC to connect to the access database)
This way you wouldn't even have to have mysql running locally if the hit is too high on your local machine and it should be pretty straightforward in that you shouldn't have to make to many changes to your vba code.
Of course, whether this will do it depends on what else is going on in your access db
If not you could try using php and using the PHP Command Line Interface (CLI) which you should be able to call as an external executable from Outlook. Just pass php.exe the name of the php script you want to run
UPDATE:
I am not a VBA expert by any means but it looks like the shell function would let you run the PHP CLI from within VBA
Shell("path/to/php.exe phpscript.php")
http://msdn.microsoft.com/en-us/library/xe736fyk(VS.71).aspx
Of course this will only work if you can get to php.exe on the wamp machine (ie is a local machine or you have network access to the appropriate folder)
Alternatively, if the Wamp server is to be a separate machine then you could trigger the php script to be run by calling a url. I think the XMLHTTP object will do this for you
Dim xmh As Object
Set xmh = CreateObject("MSXML2.XMLHTTP")
xmh.Open "GET", "http://urlofphpserver/script.php", False
xmh.Send