How to call a .py file in Unix scripting

NikhilKotagiri
NikhilKotagiri used Ask the Experts™
on
Hi guys,

Say that I can select any one of following options and it must run that particular script accordingly.

1. create cluster                                # script to create cluster
2. create JDBC                                  # script to create JDBC
3. Monitor JVM                                  # script to create JVM
 
Now, I have three .py scripts. How can I get the same options if I have this kind in a shell script.
So, if I run a Unix script these options must appear and execute the scripts
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
echo "1. create cluster"                                # script to create cluster
echo "2. create JDBC"                                  # script to create JDBC
echo "3. Monitor JVM"                                 # script to create JVM
read -p "enter your selection 1-3" a
case "$a" in
1)
  python create_cluster.pu
;;
2)
  python create_JDBC.py
;;
3)
  python create_JVM.py
;;
*)
  echo "you didn't choose 1-3"
;;
esac

Commented:
oops.. .pu should have been .py   must have been a freudian slip.

Author

Commented:
then how do I call the scripts



Thanks
Charan
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Commented:
The calls are in there already:
I've marked them  in this example

echo "1. create cluster"                                # script to create cluster
echo "2. create JDBC"                                  # script to create JDBC
echo "3. Monitor JVM"                                 # script to create JVM
read -p "enter your selection 1-3" a
case "$a" in
1)
  python create_cluster.py #<<-- this is calling the script change as needed for your actual script
;;
2)
  python create_JDBC.py  #<<-- this is calling the script
;;
3)
  python create_JVM.py  #<<-- this is calling the script
;;
*)
  echo "you didn't choose 1-3"
;;
esac

Author

Commented:
The thing is this is  a jython script. Will this work if I give python there ( I think it might work).


Thanks,
Charan
Commented:
Yes if the script not importing Java modules.
Otherwise use Jython runtime:

jython create_cluster.py

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial