Answer the question
In order to leave comments, you need to log in
PHP run script(s) on server from my script
What I want to do:
I run a PHP script on my PC, which runs the script on a server/multiple servers and passes some string of data there. After that, the script on the server should turn off. That is, as is clear from the description, the script should not run all the time, it should only run when some command follows from my script on my PC. Can this be arranged? Will sockets work for this solution?
Answer the question
In order to leave comments, you need to log in
Here are the options. The transmitter - in php:
- using curl, accesses the desired port/address on its own
- accesses the system environment via shell() and uses ssh
- uses the banal file_get_contents() in which you can also specify ports, etc.
on the side of the receiver, in any case, you will need something that will "listen" to some incoming command.
- the most obvious option, since you are talking about PHP, is to set up a web server. If you use this method, then you can execute the incoming command on the same php using eval ();
- if the Web server does not suit you, you can write a program in any modern language (python, java, c ++) that will perform its function. It will "hang" on the port and wait for the command.
- if "hanging and waiting" does not suit you, then the simplest option is a cron script on the server side, which at a certain time climbs somewhere on an external resource, checks if there are any commands for it and, if necessary, executes them.
In general, the description that is now given is very similar to the creation of a botnet) But this is a completely different tale.
Very vaguely presented. What does the sonnets have to do with it, I don’t understand.
You can run scripts on a remote server (any, not just php ) using ssh, for example: The problem is not clear, to be honest.
you can still use curl , but just do it =) it is written incomprehensibly and for sure this is a secret hacker project
possible without sockets.
You run the script at home - it knocks with a request on all the computers that it needs, and what is needed is already running there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question