Steps to diagnose the error:
- Are you using an SSH key?
- Does that key have a passphrase?
- Does it work when you run it by hand?
- Is the script running as the same user as when you run it by hand?
- Is the script running under the same environment as when you run it by hand? (e.g.
cron
jobs do not run under the same environment)
If you think all of the answers are yes, then most likely the last answer is really no. If the script is running from a scheduler like cron
it most likely does not run with the same environment as when you run it by hand. The way I normally solve this is to use a shell script between the scheduler and the Perl script:
#!/bin/bash
source /home/USERNAME/.profile
#set any other environment variables it needs like
export CSVROOT=:pserver:USERNAME@HOST:/path/to/repo
export CVSRSH=ssh
/path/to/perl/script/script.pl