esolm has asked for the wisdom of the Perl Monks concerning the following question:

Wise ones, Below is a portion of my code. The code runs fine when I am logged in as the user. When I am not logged in, the code stops at the point where it tries to connect to the database using the odbc connection. Is there a way to run this code while not logged in?

Your help is always received gratefully. Eli
#!/usr/bin/perl # ed.pl use warnings; use strict; use DBI; print "Content-type: text/html\n\n"; print "<html><head><title>Enviroment Dumper </title></head><body>"; my ($CDS, $UPDATE, $id, $text, $sqlquery, $prodnum, $catid, $catnum, $sqlquery1, $description, $count, $pccount, $sqlquery2,$s +qlquery3, $cecount ); my (@list, @count, @pccount, @cecount); # DATABASE CONNECT*************************************** $CDS=DBI->connect('DBI:ODBC:claudonntCDS', 'xxxx') || die "error opening database: $DBI::errstr\n";

Replies are listed 'Best First'.
Re: using odbc while logged off
by tinman (Curate) on May 14, 2001 at 23:41 UTC

    You can do this if the DSN that you defined is system wide or global and not local... What is probably happening is that you've defined a user DSN, and this is not visible when you are not logged in..

    DBD::ODBC has some tips on this.. just search within the page for "Defining your DSN -- which type should I use?". That should give you the information you need to run the script while not logged in
    HTH

Re: using odbc while logged off
by arturo (Vicar) on May 14, 2001 at 23:58 UTC

    I don't know anything specifically about ODBC, but in general, if there's a difference in the way your code works when you're logged in and when you're not logged in, the first place to look is in the environment variables. There could be an environment variable defined in your .bashrc that doesn't get set when the program's running as a cron job (for example).

    Apologies if you're not running *nix and this makes *no sense* =)

    HTH!