Add pwd parameter
Pass two parameters to the script pwd and command to run
Substitute both pwd and spec command to run and execute the result
Running in the gui and outside of gui requires different commands