user3273488
user3273488

Reputation: 45

Websocket with php and python client

I am new to web-sockets, What I wanted to achieve is run some bash script on my linux pc that is behind the NAT, I have a server running PHP, I was thinking to use websockets, I want to run a python websocket client which listens to my PHP server and run some bash scripts on certain events. I am not sure if this is possible or makes any sense at all. Hope somebody will point me to right direction??

Upvotes: 0

Views: 2233

Answers (2)

user3273488
user3273488

Reputation: 45

I found a solution, I am using the python client from https://pypi.python.org/pypi/websocket-client/ for the client machine and using Ratchet http://socketo.me/ for my LAMP server, my client listens to the message from server and runs the script and sends back the output using same socket (OR open up the reverse ssh connection to my server and I can SSH to my client machine)

Upvotes: 1

user149341
user149341

Reputation:

No, this doesn't make sense.

Javascript applications running in web browsers can make a connection to a WebSocket server, which runs as part of a web server. While it is possible (if difficult) to connect to a WebSocket server using a non-browser-based client, doing so has limited utility.

If what you want to do is launch shell scripts from a web server running PHP, you don't need sockets at all, Web- or otherwise. Execute the scripts using shell_exec() or proc_open().

Upvotes: 1

Related Questions