News for hackers. Stuff that matters.
Re:Help Message for Shell Scripts by hansdieter1337 on Tuesday July 07, 2020 @07:43PM (#23765539)
Even better: Don’t use bash. I started using Python instead of bash. It’s way better to read and more maintainable. If I need the performance of native-Unix commands, I can still use them using subprocess.
Re:Help Message for Shell Scripts by ChAns0n on Wednesday July 08, 2020 @03:15AM (#23767663)
Python is not as handy/efficient as bash when you want to utilize some existing Unix commands. And normally it’s crucial to stop bleeding fast if something bad is happened to you server/cluster
Re:Help Message for Shell Scripts by argonauts12 on Thursday July 09, 2020 @12:30AM (#23776947)
I've been migrating shell scripts to python and have found the 'sh' library invaluable for pulling in pure CLI commands from the bash script and adding to the python implementation. http://amoffat.github.io/sh/ It's essentially an abstraction layer above subprocess. Quick example - to use ifconfig natively in python:

from sh import ifconfig print(ifconfig("wlan0"))

Re:Help Message for Shell Scripts by ben509 on Tuesday July 07, 2020 @08:19PM (#23765767)
Python is surprisingly bad at managing subprocesses, though. Read the subprocess docs closely, it's quite easy to get deadlocks if you try to compose operations the way you can in bash.
Re:Help Message for Shell Scripts by aflag on Tuesday July 07, 2020 @09:22PM (#23766050)
There are libraries that fix that: https://pypi.org/project/sh/ if you are in position to use external libraries.
Re:Help Message for Shell Scripts by drewbug on Tuesday July 07, 2020 @07:44PM (#23765542)
bash is everywhere
Re:Help Message for Shell Scripts by nhumrich on Tuesday July 07, 2020 @07:46PM (#23765559)
So is python
Re:Help Message for Shell Scripts by zeroimpl on Tuesday July 07, 2020 @07:47PM (#23765578)
But which python?
Re:Help Message for Shell Scripts by fredfjohnsen on Wednesday July 08, 2020 @10:30AM (#23770212)