This is how mine is set up on a Synology DS415+ DSM 6.0; Perl 5.24.0-0066; Tvheadend 4.1.2389-1
I placed tv_grab_file in /usr/bin and chmod 755 to make it readable and executable. It is owned by root and group is root.
I edited the cat line in tv_grab_file to /usr/local/zap2xml/xmltv.xml - This is where I have the zap2xml files and the created xml file xmltv.xml. This folder is chmod 777 (Prob could change that to 755) In your case you would use /volume1/Tvheadend/xmltv/ instead of /usr/local/zap2xml
In /usr/local/zap2xml is zap2xml.pl, zap2xml.sh, they are chmod 755 and owned by admin, group users. After zap2xml is run it creates the xml file xmltv.xml.
zap2xml.pl has been modified so it would run with the version of the synology perl package. All the instances of JSON have been changed to JSON::PP, I have attached a copy of the file I use.
zap2xml.sh is the script I use to run zap2xml.pl it contains command line parameters. I am currently using tvguide (-z), I was using zap but it required a second read to get the episode info as S00E00, whichever one you use be sure to set up your favorite channels to limit the file size and bandwidth used. The -o option is used to tell it what to name the file and where to put it, the -d is the number of days to get I currently am using 3 days while testing I set it to 1. The second perl line parses the file to remove empty display-name tags which were causing tvheaded to crash on import.
perl /usr/local/zap2xml/zap2xml.pl -z -u USER -p PASS -d 3 -o /usr/local/zap2xml/xmltv.xml -U -T -e
perl -ni -e 'print unless /<display-name><\/display-name>/' /usr/local/zap2xml/xmltv.xml
I have the zap2xml.sh file scheduled to run every morning in DSM using Control Panel > Task Scheduler > Create > Scheduled Task > User Defined Script - Run as root, Scheduled daily once a day at 5:30, Run command /usr/local/zap2xml/zap2xml.sh
In tvheadend I have the tv_grab_file enabled Config > Channel/EPG > EPG Modules - Enabled Checkbox and then scheduled to run at 6:30 daily Config > Channel/EPG > EPG Grabber > Cron multi-line: 30 6 * You can modify your schedule time and frequency as you see fit.
Hopefully this helps you get the episode grab working.