I have a python script for testing purposes that just echos back the args. The file is echo_test.py located in my home directory and has this inside:
#!/bin/env python3
import sys
def main():
print(" ".join(sys.argv[1:]))
return 0
if __name__ == "__main__":
sys.exit(main())
If I run the following 2 commands from a bash terminal I will get 2 files (echo.txt and echopy.txt) both with the word hello in them.
echo hello > echo.txt
echo_test.py hello > echopy.txt
Now in LibreCalc I have the following functions to test the command:
sub TestLinuxCommands
ExeLinuxCommandSync("echo hello > echo.txt")
ExeLinuxCommandSync("echo_test.py hello > echopy.txt")
end sub
Function ExeLinuxCommandSync(command as string)
'build shell command
shellCommand = "-c '" & command & "'"
'run command
shellResponse = Shell ("bash", 0, shellCommand, true)
End Function
After running the TestLinuxCommands function, my home directory has both text files, but only the one using the system echo command has text in it. I cannot understand why there is a difference when running the python script from shell within a macro vs running directly from the terminal.
Any ideas?
Thanks,
John Vickers