Call custom menu action using python
You just need to swap your last call with the one you want to use.

For example if you want to export to gltf use

bpy.ops.export_scene.gltf(filepath='path/to/file.gltf')


For stl its

bpy.ops.export_mesh.stl(filepath='path/to/file.stl')


If you get an error when running the script, that may mean that the addon is not enabled. You can use the addon_utils module to enable an addon.

import addon_utils
addon_utils.enable('addon_name')


where "addon_name" is the addons file/folder name within the addons folder.

You can also enable addons on the CLI when starting blender.

blender -b -addons io_scene_3ds,io_import_dxf file.blend -P script.py