Hi,
I need to list and modify DNS records within Cpanel Hook perl code. I assume I have to use Cpanel API's as it runs as the cpanel user and needs privilege escalation to modify the DNS zone files. I have tried various methods without success ....
What is the recommended method of doing this? A working example of listing zone records and modify one would be greatly appreciated.
Thanks
Murray
I need to list and modify DNS records within Cpanel Hook perl code. I assume I have to use Cpanel API's as it runs as the cpanel user and needs privilege escalation to modify the DNS zone files. I have tried various methods without success ....
Code:
Cpanel::API::execute( 'ZoneEdit', 'add_zone_record', { domain => $domain, name => 'autoconfig.' . $sub, type => 'CNAME', cname => $domain . '.' } ); # didn't work
use Cpanel::ZoneEdit;
my %result = Cpanel::ZoneEdit::api2_fetchzone_records( { domain => $domain } );
my $filename = '/tmp/dumper.txt';
open(my $fh, '>', $filename) or die "Could not open file '$filename' $!";
use Data::Dumper qw(Dumper);
print $fh Dumper \%result;
close $fh; # this just returned undefined
Thanks
Murray
Last edited by a moderator: