I have a python web application and I would like to run multiple scripts from it. Scripts are written in various languages, like bash, lua, perl, c++, ruby, etc. The thing is that I would like to first parse the script to replace the predefined building blocks with actual numbers. So for example, let’s say I have the following bash script:
#!/bin/bash
ping -c 3 {{ip}}
Then I would like to pass that script into a wrapper with all the variables the script will need – in this case just the ip variable. The wrapper should replace all the variables with actual values, so if we inputed the ip variable as a value = 10.1.1.1, then the script should become:
#!/bin/bash
ping -c 3 10.1.1.1
And I want this functionality for all of the programming languages. So I’m using python, which should in turn use some kind of wrapper that accepts a script + arguments, and outputs corresponding output script.
I’ve found swig already, but don’t know if it does what I want, so suggestions are greatly appreciated.
Thank you
It sounds like you want m4, which would handle this easily for all scripting languages. C++, being a compiled language, would be a totally different undertaking, but I’ll assume you didn’t really mean that.
There are multiple free m4 implementations; it’s already going to be on every Linux box.
You definitely don’t want SWIG, it does something completely different.