Hans-Jürgen Schönig schrieb:
> ...
> I am writing a perl program that should insert data into a database. It
> works perfectly well when starting the script manually. When the
> starting the script as cron (same user), it collapses ($fehler = 32 512
> which I don't know and can't find).
> 
> $fehler=system("psql $new $pguser < $upload/working 2> /dev/null ");
> 
> Is there any smarter solution using Perl and what in hell means 32
> 512???
> ...

Yes, you might use the perl DBI module. This supports pg. Then
you can code like this:

        my $conn;
        my $dbname = 'foo';     # Your database's name.
        my $tablename = 'foobar';
        $conn = DBI->("dbi:Pg:dbname=$dbname", $pguser, '', {} );
        # your SQL-stuff, like:
        $conn->do("INSERT INTO $tablename (column1) values ('$data')");
        $conn->disconnect;

Just to give you an idea. :-)

What means error 32515?

Let me site some text from the perlfunc man page

        system LIST
                Does exactly the same thing as "exec LIST" except
                that a fork is done first, and the parent process
                waits for the child process to complete.  Note
                that argument processing varies depending on the
                number of arguments.  The return value is the exit
                status of the program as returned by the wait()
                call.  To get the actual exit value divide by 256.
                ...

Ok, dividing 32512 by 256 gives me 127. 

127 is the exec's (and bash's too) return code if the command
could not be found.

Cron jobs start with a reduced environment. Maybe something
important is missing, at least a search path and psql isn't
found. Try to use an absolute path. Try to run this command as
batch job, don't throw it's output away and look the resulting
e-mail message.

Good Luck!

Martin

-- 
Dipl-Ing. Martin Jacobs 
Registered Linux User #87175, http://counter.li.org/

Reply via email to