Not able to write a global variable to an file with echo command
-
I'm trying to get an current global value writen to an .g file for restore purposes with an echo command.
But either i'm getting the construct wrong, or SOMETHING, because it won't write the actual varriable.
The macro is as following:
; /macros/Toggle Chamber Lights v2.0 ; Used to toggle build camber LEDs on / off ; Save the current sb_leds status if exists(global.sb_leds) if global.sb_leds = "n-off" ; do nothing elif global.sb_leds = "n-on" ; do nothing else echo >"/sys/lib/led/sb_leds-restore.g" "; sb_leds status value to restore" ; create/overwrite file echo >>"/sys/lib/led/sb_leds-restore.g" "set global.sb_leds = {global.sb_leds}" ; save the current sb_leds status ; Check if the LEDs are on or off, and act accordingly if global.sb_leds = "n-off" M98 P"/sys/lib/led/sb_leds-restore.g" ; restore the sb_leds status from before they got manually turned off elif global.sb_leds = "n-on" set global.sb_leds = "n-off" set global.sb_nozzle = "off" else set global.sb_leds = "n-on" set global.sb_nozzle = "on"
When i run that macro without global.sb_leds being either "n-off" or "n-on" it does create or rewrite
/sys/lib/led/sb_leds-restore.g
as expected, BUT it dosn't input the current global.sb_leds value. It just returns the exact line as stated in the echo command:; sb_leds status value to restore set global.sb_leds = {global.sb_leds}
Is this the intended behaviour, or have i stumbled upon a bug?
RRF / DWC 3.4.2rc1
-
Ok, i've gotten somewhat closer to the result i want. But still not there.
For instance if
global.sb_leds = "ready"
when i run the command, i want the line written to/sys/lib/led/sb_leds-status.g
to be:set global.sb_leds = "ready"
.What i've achived so far is to get
ready
, but it leaves out the quotation marks and it writesset global.sb_leds = ready
.The code i run to yield the results mentioned above:
; /macros/Toggle Chamber Lights v2.0 ; Used to toggle build camber LEDs on / off ; Save the current sb_leds status if exists(global.sb_leds) if global.sb_leds = "n-off" ; do nothing elif global.sb_leds = "n-on" ; do nothing else echo >"/sys/lib/led/sb_leds-restore.g" "; sb_leds status value to restore" ; create/overwrite file echo >>"/sys/lib/led/sb_leds-restore.g" "set global.sb_leds = "^global.sb_leds^"" ; save the current sb_leds status ; Check if the LEDs are on or off, and act accordingly if global.sb_leds = "n-off" M98 P"/sys/lib/led/sb_leds-restore.g" ; restore the sb_leds status from before they got manually turned off elif global.sb_leds = "n-on" set global.sb_leds = "n-off" set global.sb_nozzle = "off" else set global.sb_leds = "n-on" set global.sb_nozzle = "on"
-
You have to quote the quotes
The best way to check is with echo in the console
Try thisecho "test " ^ """"^{global.myGlobal}^""""
Then extend to
echo >> "filename" "test " ^ """"^{global.MyGlobal}^""""
-
@owend said in Not able to write a global variable to an file with echo command:
You have to quote the quotes
The best way to check is with echo in the console
Try thisecho "test " ^ """"^{global.myGlobal}^""""
Then extend to
echo >> "filename" "test " ^ """"^{global.MyGlobal}^""""
I feel like i've tried every possible variant of that too. It throws an error about expecting an expression each time! If you have an idea on exactly how that codeline should look please enligthen me!
-
echo >>"/sys/lib/led/sb_leds-restore.g" "set global.sb_leds ="^ """"^{global.sb_leds}^""""
-
@owend
Yeah that sure worked! Looks corny with all those quotation marks. But what, ever it worked -
-