Retrieve a command displayed in the Terminal window

Hello
I am looking to retrieve the information from an order that appears in the terminal.
For example, I would like to retrieve the command G1 Z + 20 in order to stop the printer because on detection of the end of the filament the printer waits for nozzle and bed in heating, but if the problem monitors at night the printer can stay for hours in this state, I prefer to be able to turn it off.
Do you know a Plugin which allows to retrieve the info and to be able to execute behind for example a Gcode
Thank you

It sounds like you're saying...

  • you get a filament runout condition, say, at night
  • when this happens, some script runs which includes something like G1 Z+20 or similar
    • when this happens, you want to do something like M104 S0, M140 S0, M107

You might consider triggering from the runout condition instead. There may be a way of incorporating a G4 (dwell) command for some number of seconds so that you could deal with it during the day... and then if you're not there at night, shut off heat.

More precisely
I incorporated the G5 code in my Gcode following the Anycubic recommendation for a resumption on power failure, I do not know if this code is determining for a lack of filament by test what I note is that when I simulate a filament failure on a print launched on my Octoprint SD card goes up the code G1 Z20 +
The firmware should I think send the stop command and raise the head pending change of filament, but leaves the bed and the head warm, I wanted that when this code is detected that the machine cuts the temperature of the bed and the head

thank

come back to my comment actually this is what I want to do (with the commands (M104 M107 etc ..) I need to check if Octoprint can interpret the pause when printing via SD card and that there is a end of filament. I'm going to check that, if Octiprint sees the pause effectively, I can insert the commands in the Gcode script (Pause.)

I make the requests and the answers :grin: but I wanted to check, On Octiprint in the Terminal we do not recover the stop and the pause we just see the code G91 Z-50 appear.
Hence the idea of ‚Äč‚Äčrecovering a Gcode
Like if you see the code G91 execute this GCODE or maybe there is a pluggin that does it but I haven't seen anything about it
Thanks, have a good day

Perhaps someone else knows how to do this. :crossed_fingers: