When I try running :
cmd := exec.Command("bash", "-c", "docker ps")outp, err := cmd.Output()log.Print("outp", outp)if err != nil { log.Fatalln("Starting command failed:", err)}
I am having error :
exit status 127
even though docker is installed and docker ps
works from terminal, and works if I run the code from a GO file (not using FN project). I think that having this code as a function using FN project causes the terminal to not find commands like docker and many others.
trying the following code :
cmd := exec.Command("docker", "ps")
gives this error :
exec: \"docker\": executable file not found in $PATH
I tried a lot of other commands as well even ls
doesn't work. Anyone had this problem before ? I am thinking it maybe a configuration that I need to do or path problem that needs to be set for the exec command or FN project ... (I am on Ubuntu 22.04 and everything is updated) Any help is greatly appreciated.
[Edit]My FN project environment after executing the suggested code thanks to Eik is :
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binHOSTNAME=2d6affdfa0d4FN_MEMORY=128FN_TYPE=syncFN_FN_ID=01HZ5VWQM6NG8G00GZJ000003QFN_APP_ID=01HZ5VT0E7NG8G00GZJ000003PFN_LISTENER=unix:/tmp/iofs/lsnr.sockFN_FORMAT=http-streamHOME=/home/fn