I am new to macros.
Objective:
Make the python script locally on the system and add code to it(to spawn a shell) and finally execute the script all using LibreOffice macros.
Code:
Sub Main
Shell("bash -c 'touch openshell.py'")
Shell("bash -c 'echo import os > openshell.py'")
Shell("bash -c 'echo os.system("gnome-terminal 'sudo apt-get update'") >> openshell.py'")
Shell("bash -c 'python -m openshell.py'")
End Sub
Error:
BASIC syntax error.
Parentheses do not match.
Interestingly, openshell.py script is created and the import os command is working.
But there is an issue with " escaping in the Shell("bash -c 'echo os.system("gnome-terminal 'sudo apt-get update'") >> openshell.py'")
How to properly escape and add the above python code to the already created openshell.py without an error using macros and execute it ?