The script content
#! /bin/bash
 
SERVER=$1
 
echo "Dumping package List on: $SERVER"
/usr/bin/ssh -q -x -l root -o ConnectTimeout=10 $SERVER  dpkg --get-selections > /etc/dpkg.list
if [[ $? -ne 0 ]]; then
        ssh -q -x -l root -o ConnectTimeout=10 $SERVER  rpm -qa > /etc/dpkg.list
        if [[ $? -ne 0 ]]; then
        echo "Cannot connect to $SERVER"
        fi
        exit
fi
 
the script is 777
and runs fine when I try through the console : executed under the backuppc user
I tried running is using:

/bin/bash /usr/local/BackupPC/customScripts/prepareLinuxServer.sh vip-consult.co.uk
 
Executing DumpPreUserCmd: /bin/bash /usr/local/BackupPC/customScripts/prepareLinuxServer.sh vip-consult.co.uk
Dumping package List on: vip-consult.co.uk
/usr/local/BackupPC/customScripts/prepareLinuxServer.sh: line 12: /etc/dpkg.list: Permission denied
 

/usr/local/BackupPC/customScripts/prepareLinuxServer.sh vip-consult.co.uk
Output from DumpPreUserCmd: /usr/local/BackupPC/customScripts/prepareLinuxServer.sh: line 12: /etc/dpkg.list: Permission denied
 
sudo /usr/local/BackupPC/customScripts/prepareLinuxServer.sh vip-consult.co.uk
Output from DumpPreUserCmd: Exec of sudo /usr/local/BackupPC/customScripts/prepareLinuxServer.sh vip-consult.co.uk failed
2014-02-07 22:14:44 DumpPreUserCmd returned error status 256... exiting



Kind Regards Chris