Help – exec.Command() returning an exit status 1, but can’t figure out why

Written by
reddit
Link to Post

https://www.reddit.com/r/golang/comments/b0bmg6/help_execcommand_returning_an_exit_status_1_but/ by 

I’ve used exec.Command() many times, but now it’s throwing an error and I don’t know why. There’s two of these commands that are failing – one moves a file from the current directory to a subdirectory, and the other removes the file from the directory. The commands look like this:

command := ""rm " + title + """ err := exec.Command("/bin/bash", "-c", command) if err != nil { log.Fatal(err) } 

command := ""mv " + title + " pdfs"" err := exec.Command("/bin/bash", "-c", command) if err != nil { log.Fatal(err) } 

The terminal returns this:

2019/03/12 13:04:49 &{/bin/bash [/bin/bash -c "mv 2018MobileThreatLandscape-Appendix.pdf pdfs"] [] <nil> <nil> <nil> [] <nil> <nil> <nil> <nil> <nil> false [] [] [] [] <nil> <nil>} exit status 1 

However, if I copy/paste the command into my terminal, it executes right away! Again, I’ve used this command many times but it’s only now giving me issues.

submitted by /u/bmw417
[link] [comments]

Article Tags:
· ·
Article Categories:
reddit

Leave a Reply