-2

I know how to program a python, but I have no idea about Unix, so how can I create two .sh files to compile and execute my python program. For example, my program named hello.py and I have two files named compile.sh and execute.sh, I want to invoke compile.sh then hello.py will be compiled, and invoke execute.sh then hello.py will be executed. Thanks!

jason
  • 1
  • 1

1 Answers1

0

Instead of writing Shell scripts (the .sh files) you can just open a terminal and do stuff from there, see http://www.dummies.com/computers/macs/mac-operating-systems/how-to-use-basic-unix-commands-to-work-in-terminal-on-your-mac/ - whatever you do there is executed live as if it was a Shell script. By opening a terminal and simply typing

python my_script.py

you trigger python to first compile the code to *.pyc files and then execute it. No special steps are needed! Whatever you type in the terminal, you can also save it as a shell script and run it at a later point. Shell scripting is taught at many websites like https://www.shellscript.sh/ and others, google is your friend.

mkastner
  • 103
  • 10