0

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??

2 Answers 2

1

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().

Sign up to request clarification or add additional context in comments.

1 Comment

I need to exucute the scripts on clientpc(behind nat) not on a server, I have been using reverse ssh connection to achive this and get it running but was looking for better alternative.
1

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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.