perl <<'EOF'
use warnings;
use strict;

my $server = 'server_placeholder';
my $ip = 'ip_placeholder';
my $backupserver = 'backup_placeholder';

my $manageagent = '/usr/sbin/manageagent';

die "[!!] Failed to locate manageagent on $backupserver. Is this a CDP server?\n"
    unless -f $manageagent;

my $output = qx(manageagent --add --agentip $ip --name $server --cpanel);

if ($? == 0) {
    print "[*] Agent added successfully.\n\n";
} else {
    print "[!!] Agent not added successfully. Please review the output below and escalate if needed.\n\n";
}

print "Command output:\n$output";
EOF