I am trying to execute the command using the sh
file as given below:
#!/bin/bash
echo "executing......................................"
wget -i http://example.com -O /dev/null
Which is running properly when I am accessing directly from my desktop folder.
But when I integrate it with my golang project for example:
I created a folder named myProject/sh
and pasted the file there.
Now using cron in my another package I am trying to access the test.sh
file.
func RunCron() {
c := cron.New()
c.AddFunc("10 * * * * *", ExecuteFunction)
c.Start()
}
func ExecuteFunction(){
fmt.Println("test----------------")
utils.ExecuteCommand("sh "+config.GetBasePath()+"sh/test.sh")
}
Now it outputs something like
test----------------
Result: executing......................................
exit status 4: --2018-01-16 18:25:10-- http://example.com
Resolving http://example.com)... 1.1.1.1
Connecting to example.com (example.com)|2.2.2.2|:8080... failed: Connection refused.
No URLs found in example.com.
I am unable to figure out that why the same code runs well in my desktop folder but stops executing inside my project's folder. Can you please save my time by telling me whats wrong am I doing?
Thanks!