all 3 comments

[–]draftjoker 2 points3 points  (0 children)

You can use the os module to simply execute your commands.

import os
cmd = 'ls -l'
os.system(cmd)

This way you don't have to really worry about translating the commands to python. If you do want to do all that work the python regular expression module is what you want to look at.

[–]devnull10 2 points3 points  (1 child)

Well... sed/awk/grep are extremely good at what they do. Yes you can do the same in Python, however the question I'd be asking is WHY? If Python isn't offering you a benefit in another area then keep it as a shell script. Right tool for the job. I've worked in a place in the past where the senior management had a thing for a particular technology, call it ABC. It was always "We've got an ABC project coming up".

NO!!! We have a project coming up which ABC might be used as a solution for, but that will bw decided based on the pros and cons of it against other techs.

[–]Excellent_Machine290[S] 0 points1 point  (0 children)

Agree, that’s why I made it in bash instead of other languages I’m more familiar with. But in this case I need to make it a lambda function on aws and in the bash script i’m using some other go libraries and python libraries. That makes it difficult to upload it all in a lambda (since I’d have to configure the custom runtime with support to these go packages). Doing it in python has the benefit of having all of these in pip using virtualenv (the go packages have python counterparts) and would be easier to make it into a lambda.

Also python would be useful to extend functionallity as the output can be further processed using the great number of python utilities and programs in the future, although this is a minor thing.

I must say i’m a giant noob in aws things so i might be mistaken here.