Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new to freebsd and have a problem: my script uses wget. when I call it from the command line it works fine and I see the output like this:

--2011-09-22 15:55:58--  http://svarog.***/monitor/reply.PHP?port_id=312342
Connecting to 83.***.***.2:3128... connected.
Proxy request sent, awaiting response... 200 OK
Length: 8 [text/HTML]
Saving to: `reply.PHP?port_id=312342'

     0K                                                       100% 1.14M=0s

2011-09-22 15:55:58 (1.14 MB/s) - `reply.PHP?port_id=312342' saved [8/8]

but whet it's called from cron the output is as follows:

--2011-09-27 10:30:05--  http://svarog.***/monitor/reply.PHP?port_id=318437
Resolving svarog.***... 83.***.***.2
Connecting to svarog.***|83.***.***.2|:80... failed: Connection refused.

so I guess my problem is in proxy settings and tried to check it, but:

echo $http_proxy
http_proxy: Undefined variable.

and looking on env output I see no variables corresponding to my proxy.

So: how can I find these settings used by wget and how can I then use it under cron?

share|improve this question

Above solution about

.wgetrc give me an idea on how to use wget with proxy.

I'm using fedora 16.

Other than copy the .wgetrc file into specific folder, I just need to configure the .wgetrc file.

I opened wgetrc configuration file in /etc/wgetrc and edit the proxy as below :

# You can set the default proxies for Wget to use for http, https, and ftp.
# They will override the value in the environment. 
  https_proxy = 
  http_proxy = 
  ftp_proxy =

# If you do not want to use proxy at all, set this to off. 
  use_proxy = on

Voila , the cron job run perfectly with proxy enable using wget


share|improve this answer
up vote 0 down vote accepted

i've figured it out!

wget reads settings not only from variables but from .wgetrc file which i found in root directory. i cped this file to /usr/home/nstat (nstat is my user to run scripts) and it seems to work!

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .