Page 1 of 1

[Linux Tipp] Easiest way to run Bash commands with GP

Posted: Jun 4th, '18, 20:23
by MSandro
Hi, because I've needed a better interaction between GP and my OS (Linux), I've tried to find a easy solution to run Bash-Command from GP.

I've wrote the following short script to make this posible:

Code: Select all

#!/bin/bash
while :
do
  $(head -1 cmd.txt)
  > cmd.txt
done

This script is able to check the first line of the file "cmd.txt" and execute it. After this it clears the file.

If this script runns in background, you can do e.g. the following in GP:

Code: Select all

self_writeFile 'cmd.txt' 'shutdown now'
GP writes the bash command to the file and the script will execute it.

This is nothing special but I thought; I shuld share it and I will extand this script to output the result of the command to be used in GP. It should be also posible to write a Batch scirpt to do the same on Windows.