I am trying to use a tempfile so that I can pass the tempfile as an argument to a exec command.
I declare the command I am going to use as
CLI_CMD := "/home/go/src/hello/abc.sh"
xmlFile, err := ioutil.TempFile("", hostIP)
command := CLI_CMD + " " + xmlFile.Name()
I finally run the command as
cmd := exec.Command(command)
stdout, err := cmd.Output()
To confirm abc.sh is present I do
[prompt] ls /home/go/src/hello/abc.sh
/home/go/src/hello/abc.sh
Also to confirm that the Tempfile is present , I do
[prompt] ls /tmp/10.166.30.47.xml187906126
/tmp/10.166.30.47.xml187906126
I can see both of these files being present here using the ls command. I am not getting why I am getting an error which fails to find either of these files. Also what file is not found here, the .sh file or the tempfile
2019/03/08 17:50:31 fork/exec /home/go/src/hello/abc.sh /tmp/10.166.30.47.xml187906126: no such file or directory
I have tried to summarize the code to make it easy to understand.