Hi All,

Please let me know if there is a more appropriate list to post this question
to.

I'm sure that this must be one of those things that everybody but me knows
about.  When I run the following script from a DOS box command line it runs
fine:

        use strict;
        use Win32::NetResource;
        my $home = "d:"; my $logfile = $home."\\dir1\\logfile"; my $drive =
'R:';
        my $resource = {
            'LocalName'     => $drive,
            'RemoteName'    => "\\\\server\\share", };
        my $audit_dir = undef; my $DOWARN = 1;
        local $SIG{__WARN__} = 'handler';

        open(LOG, ">>$logfile") or die "Can't open $logfile! - ($!)";

        unless (Win32::NetResource::AddConnection($resource, undef, undef,
0)) {
            my $err = undef;
            Win32::NetResource::GetError($err);
            warn Win32::FormatMessage($err);
        }
        $audit_dir = "r:\\dir2\\dir3\\dir4";

        if   (chdir "$audit_dir") { &do_stuff; }
        else { warn "Can't change to $audit_dir: $!"; }

        unless (chdir "$home") { warn "Unable to chdir to $home! - ($!)";
die; }
        unless (Win32::NetResource::CancelConnection($drive, 0, undef)) {
            my $err = undef;
            Win32::NetResource::GetError($err);
            warn Win32::FormatMessage($err); die;
        }

        close(LOG);
        exit;

        sub do_stuff { return 1; }
        sub handler { 
            chomp (my $msg = shift);
            print LOG "ERROR: $msg\n" if $DOWARN;
        }

When I schedule it to run via "at" it prints the following error to my log
file:

        ERROR: Can't change to r:\data\interfac\CDW3: No such file or
directory at d:\sw_pos\store_audit_extract.pl line 82.

This is running on a WinNT Server 4.0 (build 1381: Service Pack 6) box.  If
anyone can tell me what I need to do to get it to run properly under "at",
I'd appreciate it.

Thanks,
Carl J. Bauman
Senior Business Analyst
Information Technology
Ultramar Diamond Shamrock Corporation
[EMAIL PROTECTED]
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin

Reply via email to