PolinaC PolinaC - 1 year ago 136
Perl Question

Cannot run perforce from crontab

I am trying to execute perl script that works with perforce, from crontab. This is my perl code:

print `/usr/local/bin/p4 filelog /projects/config.json`;

I am getting error:

Perforce client error:
Connect to server failed; check $P4PORT.
TCP connect to perforce:1666 failed.
Name or service not known

The same command is working smoothly from cli. Any ideas what can i do with it?

Answer Source

I found the solution is to set the env vars in perl code:

    $ENV{'P4PORT'} = '...';
    $ENV{'P4CLIENT'} = '...';
    $ENV{'P4USER'} = '...';
    $ENV{'P4PASSWD'} = '...';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download