aspose file tools*
The moose likes Jython/Python and the fly likes Passing array from shell to python Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Jython/Python
Bookmark "Passing array from shell to python" Watch "Passing array from shell to python" New topic
Author

Passing array from shell to python

sharad jain
Greenhorn

Joined: May 04, 2013
Posts: 14
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

Joined: Mar 01, 2009
Posts: 1851
    
  16

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!


No more Blub for me, thank you, Vicar.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing array from shell to python