cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: cron call to curl not working

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 30 Oct 2001 13:40:53 +0100 (MET)

On Mon, 29 Oct 2001, Kevin wrote:

> First, let me say that I am new to cURL, Perl, and Unix...so forgive me
> if I am doing something "stupid" or something only a newbie would do.
> Any help would be appreciated.

We've all been newbies. I don't mind beginners' questions posted here, not at
all.

> I am using Mac OS X 10.1. I'm using the already-installed cURL v.7.7.2.

That's the pain of release schedules and stuff I assume. That version was
released in April, more than six months ago. We've improved curl a lot since.

> Here is the gist: I have written a Perl script to log on to a particular
> website. The script works fine when run from a Terminal window, but will
> not work when run as a cron job.

Haven't we all been through that once or twice in our lives? ;-) It is
*usually* a matter of environment. Check your HOME, PATH, TERM variables when
invoked from crontab...

> Then, I am logging in to a website, then changing the particular
> information that was grabbed from the first page. Here I use the "-d"
> option of cURL to send my username and password. I have tried both
> backticks and "open" then piping in Perl:
>
> open (CURL, "curl -v -d \"UserName=username&Password=password\" -L
> \'https://www.website.com/login.html\' |");
>
> The cron job will grab the first website just fine, and perl will do its
> stuff to it, but cURL will fail to log in to the other site. Strangely,
> if I add the "--stderr '-' " command, it seems to work. Is there
> something I am missing/not doing correctly? Let me know if you need more
> information, as I know that since I don't know much about this stuff, I
> am probably leaving out some important info. : )

This certainly sounds odd. Are you somehow using information that is sent to
stderr? I can't explain why that works for you when you run perl from your
normal interactive shell.

The --stderr is normally not needed when running under unix, since you can
just as well just append "2>&1" to the right of the command line to have that
effect.

My advice: use --stderr! ;-)

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2001-10-30