Title: How to pass variables between scripts

Dear list,

I am an absolute newbie to python and would appreciate your help very much  :)

I am trying to write a little python script that wraps a set of external scripts. The external scripts are either also written in python or are simple bash scripts. My wrapping script should be able to send an argument to the first script, to execute it, to read its results and to send them then as arguments into the next script.

This is the first part that I have written so far:

#! /usr/local/bin/python
# test_exec.py

import os, sys, glob

fileList = glob.glob('/data/*.ZIP')

for f in fileList:
        try:
                globvars = {'infile' : f}
                locvars = {}
                execfile('/scripts/second.py', globvars(), locvars)
        except IOError:
                exit(0)
        print locvars


And this is what happens when calling test_exec.py

 ./test_exec.py
Traceback (most recent call last):
  File "./test_exec.py", line 19, in ?
    execfile('/scripts/second.py', vars(), results)
TypeError: 'dict' object is not callable


I tried already to modify the script in different ways but wasn't successful so far to make it running. Could you maybe help what I am missing? Further, I am not sure how the second python has to look like to actually read what is given in "globvars" and to sent its results into "locvars".

Or might os.popen* be a better option? 





-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to