On Jan 26, 11:30 am, Emile van Sebille <em...@fenx.com> wrote:
> On 1/26/2011 7:51 AM bansi said...
>
>
>
>
>
> > I have following two python scripts
> > -namelookupWrapper.py
> > -namelookup.py
>
> > The namelookupWrapper.py takes input of "memberId", "memberName" from
> > CLI and has following code snippet
>
> > idf = sys.argv[1]
> > namef = sys.argv[2]
> > real_script = "C:\\Splunk\\etc\\apps\\search\\bin\\namelookup.py"
> > r = csv.reader(sys.stdin)
> > os.execv(python_executable, [ python_executable, real_script ] +
> > sys.argv[1:] )
>
> > Wondering how would i pass csv reader object "r" as an argument using
> > os.execv() to another python script i.e. namelookup.py
>
> I suspect you're on the wrong path.  You probably want to import
> namelookup within namelooupWrapper to use the functions it defines.
>
> Consider:
>
> [root@fcfw2 src]# cat > test1.py
>
> def say(what): print what
>
> [root@fcfw2 src]# cat > test2.py
>
> #!/usr/local/bin/python
> import sys
> from test1 import say
> say(sys.argv[1])
>
> [root@fcfw2 src]# chmod a+x test2.py
>
> [root@fcfw2 src]# ./test2.py hello
> hello
>
> HTH,
>
> Emile- Hide quoted text -
>
> - Show quoted text -

Emile,
Thanks for quick response. I am not sure if "import
namelookup within namelooupWrapper" helps because they are two
independent scripts which has to be executed in sequence.
First namelookupWrapper.py running under Python 2.6 accept arguments
from stdin and uses csv reader object to read it i.e.
r=csv.reader(sys.stdin)

And then it has to pass csv reader object to another python script
namelookup.py running under Python 2.7 because it uses pyodbc to
connect to database and iterates thru reader object

Any better  ideas/suggestions will be greatly appreciated
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to