1

My script processes data, and like a flow chart, upcoming actions depend on the results of the previous action. I'd like to output text to the command line after each action, and have the script continue to execute until finished.

Something like:

  1. Execute command to an external service
  2. Poll service for its status, which might be PENDING or FINISHED
  3. Output "Still pending, will check again in n seconds" to the command line until the status changes to FINISHED
  4. When FINISHED, say so, then continue on to executing a different command
  5. Again, as before, poll status, output to command line, until finished...
  6. Finally when the last command is finished, output text, then exit the script.

All pointers are welcome. I assume something like sleep(n), recheck status, sleep(n), etc. until status shows it's finished. I assume streams will be used, but I'm not sure how to output to the command line in PHP while the script is running, rather than outputting all text after it's done.

Ideally tips involve native PHP rather than having dependencies. All execution/output is done via the command line.

LookingToLearn
  • 303
  • 3
  • 8

0 Answers0