How to wake a PC with a PHP script? - php

By enabling Wake-on-LAN on my PC, I can remotely power it on.
Suppose I want to send the "magic packet" from a PHP script. How would I do this? Would I need to use the cURL functions?

You can peek at: http://sourceforge.net/projects/wolviaphp/files/ (uses fsockopen() with 'udp://')

I have used WMI in the past, for the remote management of machines running windows.
So WMI from MS or http://www.openwbem.org/ (the open standard) might be what you are looking for.
Good luck.

Related

Sockets compatible with javascript on a remote shared server?

Basically I want to use some kind of sockets (web sockets or node.js?) but I don't really know much about them and I want to send low latency data between html pages with javascript enabled on them.
I have php installed on the shared server and socket_connect() is a function included so i'm guessing php_sockets.dll is installed. I could potentially use this, but the php script is on a remote server so I don't know if i would be able to run it?
Should I use some other language that would be installed on a normal shared server?
EDIT: I don't have shell access..
http://www.flynsarmy.com/2012/02/php-websocket-chat-application-2-0/ this should give you a pretty good start in talking to php using html5's websocket api. You don't need Node.js to implement this.

Python data passing

I need exchange data between python daemon (cluster nods send data to this daemon) and php script (apache) which, is accessed by webbrowsers. What do you recommend as technology which could establish some connection between them. Both, python daemon and apache/php is on the same machine.
Thank you.
What you are wanting to do is called IPC (inter process communication). Since these are common Linux applications I am going to refer you to this SO question which recommends Unix Domain Sockets.
For PHP look here and for Python look here.
If you want things to be synchronous use a named socket(Amazing feature on Unix systems.)
If you want things to be asynchronous use pickle(there is a php version of it too.)

howt to access COM port via script

I need to access COM port (console) via script to access our DSL modem.
It should access in such a way that I can read all the messages printed on the console and i should also send commands to the console via script .
Please let me know if it is possible in TCL or php .
Platform : Windows XP.
Also is there any way I can access the com port through script and console software such as teraterm simultaneously ?
Regards,
Mithun
It is possible to use TCL to access a serial (COM) port using the standard TCL input and output commands. The main ones that you need to look at are the open and fconfigure commands. A google search for 'tcl open com1' will bring back lots of examples.
One thing worth noting is that the open and fconfigure commands changed in recent versions of TCL, TCL 8.5 I think, so depending on the version of TCL and age of the example some rework might be needed.
You just need to open the com1: device and fconfigure it to use the communications settings that the other side expects. For example:
set fd [open "com1:" r+]
fconfigure $fd -mode 9600,n,8,1
Be aware that it can be messy to use event-driven IO with serial ports on all platforms.
Sounds like a job for Expect.

Execute JAR in PHP

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.

JavaScript (or JS+PHP) Terminal Client

Does anyone know of a JS-based terminal client? Either something that initiates an SSH connection with a remote host or even something that simply communicates with a remote PHP script to execute commands and retrieve output. Does such a thing exist?
Check Anyterm, it uses a XmlHttpRequest channel to communicate with a daemon that uses a pseudo-terminal to communicate with a shell or other application.
http://www.masswerk.at/termlib/ looks interesting as a base.
http://sourceforge.net/projects/jsterminal
but you'd have to write your own commands to connect with the host
Shell in a box could be used also with a small Asus EEE-PC:
http://code.google.com/p/shellinabox/
It works great also for virtual machines in a cloud.
So far JSDom Shell is the only thing I have found, which seems relatively barebones but practical. If there are any other more substantial options, feel free to share!

Categories