Python To ShellScripts : pytoshell

After so boring to write the same routines by python, bash (unix) and batch (windows). I want to find a way to generate bash script and batch script from a python script, so that the routines could be reused and I needn't to rewrote them again and again in different shell scripts.

I found some projects related:

Use custom C like language to write your unified script and generate shell scripts for different OS.

I like this idea, it's close to my requirement.

But there have some reasons make me give up this solution:

  • Does not have an easy way to install this program, especially on windows. You have to compile it yourself (It's a little uncomfortable as a user)
  • Implemented in OCaml which I don't familiar with
  • I don't think it's a good idea to introduce a new language for this task

It mixed python and shell command together.

All shell commands will be starts with "<" character, other codes the same with python.

All stuffs are mixed together into a single *.pysh file.

Use the pysh command to translate shell commands content into standard python source and then spawn a python to execute the python source.

I give up this solution either:

  • The way it achieve the unify script isn't my original purpose, although it have not introduce another new language and just extended a new keyword for more easy integate shell commands.
  • Depends on python, it's fine to depends on python while we developing the script, there have easy installation packages for each OS. But I don't want the final user have to install a python environment, just for run my script.

So, finally, I try to write one : https://github.com/starofrainnight/pytoshell

Comments !