Supposed to Open SHELL App (C) which i Coded as interface for my purpose
I Already know about exec and shel_exec which couldn't be helpful on this.
My Console Application which i had to OPEN on php is interactive shell and batch (Both Modes are available).
I Need to communicate to shell, not just opening and get result (like exec func).
I want to Open My Shell and Send commands to it , which can be Interactive I/O or batch I/O.
Well If No Straight solution found with php built in Function I am going to pass my command as String Parameter to console application
But Straight solutions with php built in library and behavior still would be accepted
Related
I have a C++-library (.so) for some calculations that I would like to call from Wordpress/PHP via an input formular. The promising idea to build the .so-library as a PHP extension using PHP-CPP has been fine locally on Ubuntu 14.04. But on the webserver this method failed because my webhoster doesn't support changing the extension directive in the php.ini/.user.ini. I see the following alternatives:
Build an exutable application and run it from PHP via proc_open() and send a lot of variables to the stdin of the application. Wordpress itself offers PHP plugins.
Redirect to another server where my own php extensions are supported.
Is there a way using python/web2py for that purpose?
Which would be best?
Or any other ideas?
Probably the simplest way is to create command line utility in C++ and execute it from php with shell_exec. I tried that in past and the performance was not too bad.
"Probably the simplest way is to create command line utility in C++ and execute it from php with shell_exec. I tried that in past and the performance was not too bad."
This did help. Finally I managed a build on Linux which was portable to the webserver where the website and wordpress are located. The call to the binary built from C++ was done with shell exec or popen in PHP (which one I don't remember, it was in 2018). The PHP code was finally migrated to an own wordpress plugin. Unforunately, I could not use PHP-CPP due to missing admin rights for the webderver. But the integration via shell exec or popen works fine.
I am trying to execute a python script from a php script. The python script named main.py calls many others python scripts including some special libraries like tensorflow for machine learning.
I am able to launch simple python scripts with just some print('hello') using exec, system or even popen, but the problem is when I try to execute my main.py
I already gave all the permissions to all the users.
With a quick research I could find that the problem is about the fact that the browser can't find the library tensorflow.
If I launch my program from command line, it perfectly works, so does anyone know how I can tell my browser where to get the libraries ?
Thank you
I want to extend the automation of the PacketETH program CLI using PHP
It can be done in GUI however this still means a user has to do it
Is it possible to have the packetETH run and a PHP deliver instructions, and then receive results back for manipulation?
In a broader sense, is this type of connection possible at all?
Thankyou
You can access the command line from php by using the Php System Program Execution functions. http://php.net/manual/en/book.exec.php. You can try out the exec function. It lets you execute shell commands.
To run the packeteth program from php you can use a command like the following:
exec("/path/to/packeteth/packETHcli -i lo -m 1 -f packet1.pca");
I am using phpseclib to run commands via SSH on another server. I am currently using the Interactive Shell example (See Here)
If I want to send a command, I use $ssh->write("ls -la\n"); and then I run $ansi->appendString($ssh->read()); echo $ansi->getScreen(); to see the screen output.
Is there a way for me to run commands from a form where can I use it like a web-based console?
Yes why not! Then you have to implement a form and send the command to your server. But there is a much easier way. Perhaps with ajax and fetch the return from your command line.
http://www.web-console.org/
There are a lot of projects doing exact that. When you build that on your own you have to look at security and much more.
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.