Search code examples
curlcrontcleggdrop

cannot curl from tcl (eggdrop bot) after restart freebsd/freenas-jail


I am running a freenas jail environment that run a few eggdrop scripts. One of the scripts at some point executes the command (in tcl):

set nfoc [exec curl -m 10 -s -f -k -3 --connect-timeout 3 -L "$url" -o "/tmp/$filename"]

So it downloads a file. All was working well when I set this up, however after a reboot of the jail (not even that main server, just the jail).

I get the folowing error:

Tcl error [::bc::onEncryptedText]: couldn't execute "curl": no such file or directory

I made sure the directory of the eggdrop was all chmodded to 0777, and all paths are correct.

problem only shows up after the reboot of the jail, anyone have any idea what the problem could be?

any help would be greatly appreciated.


Solution

  • Either you don't have curl installed on the host that is running your bot, or it isn't on the PATH. Since cron tasks run with a greatly reduced PATH (for various reasons, including security) you'll have to either set up the PATH within your script or use the full name of curl. Both are easy enough.

    To set up the PATH in your script, use echo $PATH in a terminal to see what it is when things work, and then do this in your script (preferably very early):

    set ::env(PATH) "/the/path/you/found/earlier/for/example:/usr/local/bin:/bin:/usr/bin"
    

    To hard-code the location of curl, use which curl in a terminal to find it, and then use that value in your script, like this:

    set nfoc [exec /usr/local/bin/curl -m 10 -s -f -k -3 --connect-timeout 3 -L "$url" -o "/tmp/$filename"]
    

    Which is best? Well, if you're calling curl from several places, it can be much easier to set the PATH, but if you're just calling it in the one spot, hard-coding a location is a very easy fix.