Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I do know how we pass one variable from python to c shell script but I am having trouble in passing multiple python variable to c shell script. Please let me know how do we achieve this. Here is the link where I came to know to pass single variable from python to c shell script.

How to pass the Python variable to c shell script

share|improve this question
    
The answer you're using as a starting point is... really quite awful; shlex.split() rather explicitly shouldn't be used in this case. – Charles Duffy Jan 30 '15 at 14:41
    
That said -- what have you tried so far, and how did it fail? – Charles Duffy Jan 30 '15 at 14:44
    
None of this is specific to csh, by the way -- the environment and argument vector are both universal concepts; passing content through them is the same no matter what language the receiving program is written in. – Charles Duffy Jan 30 '15 at 14:45
up vote 2 down vote accepted

Pass each argument as a separate argv entry:

first_var='hello'
second_var='world'
subprocess.Popen(['program_name', first_var, second_var], shell=False)

By contrast, if you want to pass multiple variables through the environment, they should both be keys in the env dictionary:

subprocess.Popen(['program_name'], env={
  'first_var': first_var,
  'second_var': second_var,
})
share|improve this answer
    
Thanks Charles, This is exactly what I was looking for as the previous solution that I referred in the question was bit confusing. – nprak Jan 30 '15 at 18:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.