Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing array from shell to python

 
sharad jain
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends

I am creating a script where on runtime passing some command line arguments like ::

$./newServerStatus.sh dev_case_01 dev_auth_01 dev_rnp_01 ...

Now I need to use these parameters in a shell and from there this array needs to be passed to a python. Can someone please help me how should I pass and retreive this. Any help would be greatly appreciable.

Thanks
Sharad
 
chris webster
Bartender
Posts: 2407
32
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure how you're calling your Python script, but here's how you can process command-line arguments inside Python:

http://www.tutorialspoint.com/python/python_command_line_arguments.htm

For passing arguments from a Unix shell script to another process (e.g. Python), there seems to be a special variable "$@" which I think represents all the arguments for the current (Unix) process as separate strings. Some more information here:

http://www.tutorialspoint.com/unix/unix-special-variables.htm

HTH!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic