Yes, in Python it would be easy to create a program to manage other scripts . bat, and create them and describe them according to IP.
But it would be even easier, and more maintainable, to exchange at once the various sets of ,bat that you have there for a single Python script that manages everything --
.bat is a found way of executing commands from the old DOS in batch - not even a shell lingugem, and you have to do some contortions to such trivial things in "real languages" as an if or a for.
To manage external scripts, you can use the frameworks library - jinja2 - it is the default template language of Flask,and perhaps other web frameworks. But the idea of a template language is to just read a "base" file, and replace well-defined language markups with variables controlled from Python. In this case, instead of filling in the data from an HTML page to serve on the Web, you would use Jinja to fill in the Ips in a . bat,and burn to disk the resulting file.
The Jinja documentation is here: https://jinja.palletsprojects.com/en/2.10.x/
Now, in the line that the other answers point to, it may be much more practical to use Python at once instead of . bat
With the command line application framework click
it is easy to automatically create cmd commands that trigger actions in functions of a Python program, already with all parameters and arguments preset, and a help system printed on the automatically generated terminal.
And there is a whole family of forms to, from within the program in Python, call external commands like a file . bat, case these commands do things that take a little more time to do in Pythn (network-specific configuration commands, for example) - but if they are commands like copying files, manipulating text data, etc.. it’s simpler to do everything in Python anyway.
The documentation of the click: https://click.palletsprojects.com/en/7.x/
And finally, to call other commands, can be used from os.system
- and you can shorten the call so you don’t have to write too much:
from os import system as S
S("ipconfig")
When, if it really is a critical project, use the module suproccess
and its various functions to have control of the data generated by each external process, output code, to be able to call external commands in parallel, etc.
Documentation of the subprocess: https://docs.python.org/3/library/subprocess.html
In python there is lib
subprocess
with her you for performing operations in cmd. Follows link of her documentation– Tmilitino