I'am expecting something like this:
"Run this script as root so that you will have in a text file, the ports that are being used"
After you add the proper comments to this text file adding this to each line (example)
# Comment-This port is for Oracle Apex
then you run this other script to add the content of this text file to the /etc/services.
This must be run by root.