• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

Passing array from shell to python

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
reply
    Bookmark Topic Watch Topic
  • New Topic