diff --git a/fsl/utils/fslsub.py b/fsl/utils/fslsub.py
index 2a667e512fcd57565c0c3fbf6d863c47570d6808..d679a3a3a80c347f97be9092da6d7c466564e02b 100644
--- a/fsl/utils/fslsub.py
+++ b/fsl/utils/fslsub.py
@@ -252,7 +252,7 @@ if name_type == 'module':
     func = getattr(import_module(name), func_name)
 elif name_type == 'script':
     # retrieves a function defined in the __main__ script
-    local_execute = {{'__name__': '__not_main__'}}
+    local_execute = {{'__name__': '__not_main__', '__file__': name}}
     exec(open(name, 'r').read(), local_execute)
     func = local_execute[func_name]
 else: