wget doesn't see proxy under cron

2

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?

k102

Posted 2011-09-27T07:13:43.603

Reputation: 147

Answers

0

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!

k102

Posted 2011-09-27T07:13:43.603

Reputation: 147

1

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://127.0.0.1:3030/ 
  http_proxy = http://127.0.0.1:3030/ 
  ftp_proxy =  http://127.0.0.1:3030/

# 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

=)

Cyroz

Posted 2011-09-27T07:13:43.603

Reputation: 11