Further Uses of the EPP Wrapper Script

by Mark Luszniak on May 17, 2013 in Technology
Technology Image

In an earlier blog posting, I described the use of a Python ‘wrapper’ script. Its initial use was to enable a single Process to initiate two (or more!) external applications. I recently stumbled across an issue that I solved using the ‘wrapper’, and thought I’d post my findings. First of all, let’s refresh our memory on the contents of the script itself.

import os
import sys

def main():
   args = ""
   for arg in sys.argv[1:]:
      args = args + arg + " "
   arglist = args.split( "script:" )
   for arg in arglist:
       arg = arg.strip()
       arg = arg.replace("'", '"')
       if len( arg ) > 0:
           ## print( "\n\n" + arg )
           os.system( arg )
if __name__ == "__main__":

The command I wanted to send to the EPP was trivial: on a Unix/Linux command line it would be represented as:

cat file1 file2 > newfile

When this was reformatted and sent to the EPP node it kept generating errors. I never fully determined the root cause, but it looked as though the re-direction operator was causing problems:

/bin/cat {inputFile0} {inputFile1} > {compoundOutputFileLuid0}.txt

My initial attempts at fixing this involved wrapping the command in double-quotes, but to no avail. I think I tried every permutation, but it’s likely that I missed a few. After becoming frustrated by this, I remembered that when we were first testing the ‘wrapper’ script we tested output re-direction, and so I took another approach which was to wrap my command in a call to the ‘wrapper’ script, and see if that made a difference. In less than a minute, I’d tweaked my EPP command, and the ‘wrapper’ script was coping with the re-direction operator without drama. Here’s the final EPP syntax:

python epp_wrapper.py "script:/bin/cat {inputFile0} {inputFile1} > {compoundOutputFileLuid0}.txt"

Recall that on my system, the ‘wrapper’ script is called epp_wrapper.py