AstonJ

AstonJ

What kind of Bash scripts have you written?

Inspired by this post by @stefan.jarina, I’m curious about the kind of Bash scripts you’ve written and whether you still use Bash given there are a lot of scripting languages around now…

Most Liked

dimitarvp

dimitarvp

I can’t shut up about the last task I did for one of my former customers: I made a script that scraped our own app’s invoice pages and printed all the scraped pages to PDF. It also utilized parallel so several downloads and PDF creations were happening at the same time.

The whole script, with good comments included, is no more than 45 or so lines yet it was one of the most productive scripts I have ever written. Our business people – who wanted the PDF invoices – were thrilled.

stefan.jarina

stefan.jarina

Just a bit of a context to why even have a need to write a bash script.

I mostly write automation, for windows in powershell, for linux in python. and mostly leveraging ansible.

However the need was to have a script that can be deployed to server using azure custom scripts extensions. My first idea was to simply have a thin wrapper above my python scripts, that wil install what is needed and then launch python goodness. however this proved to be a bit frustrating, because different systems have different package names, dependencies and etc.

as soon as you have to support ubuntu 18.04/20.04, red-hat/centos 7 and 8, openSUSE, oracle linux and some more…

on one system there is only python3, on other only python2, on some python3.5 on other python3.8, on some package is called libselinux-python, on other python3-selinux and so on :smiley:

I just said screw it, will write this in bash and be done with it, I can be sure, that will work reliably on every system.

my wish for 2021 is to get rid of python2 and be done with this nonsense and have everywhere only python3 so we can finally count on it in our automation :slight_smile:

PS: sorry for a small rant

tomtastic

tomtastic

I love BASH, with moderate knowledge of it you can do so much with ease.
I especially like using its arrays and rematch regex for quick utilities where reaching for Python or PERL otherwise just doesn’t seem worth the time or potential loss of portability.

Most recently I wrote a a script to scrape a visualisation graph from an external webpage, refreshing its view every 10minutes but only between core business hours, and sleeping precisely until the next day when outside those hours, displaying it directly in the terminal with iTerms imgcat :slight_smile:

But my most valuable and oft used script is one I wrote to update my DDNS IP address in Cloudflare.

Popular Backend topics Top

AstonJ
Partly interested in this so we can set up tags, but also because I’m out of touch with which frameworks are hot right now and I’m curiou...
New
DevotionGeo
For me it’s the semicolon, because I stopped using a semicolon in JavaScript, two other of my favorite languages, Elixir and Go don’t hav...
New
AstonJ
Currently a hot topic in the BEAM world, let’s start a thread for it (as suggested by @crowdhailer here) :smiley: What are your current...
New
First poster: bot
AbstractMachinesLab/caramel. :candy: An Erlang backend to the OCaml compiler. Contribute to AbstractMachinesLab/caramel development by c...
New
New
AstonJ
If you are experiencing Rails console using 100% CPU on your dev machine, then updating your development and test gems might fix the issu...
New
mafinar
So I was thinking of trying out Crystal, I had tried it multiple times but left it midway. Now that there’s a book on it and it’s version...
New
jaeyson
Sorry for the very vague noob question, I really want to ask this: When do we use async or sync code in the context of Elixir? AFAIK gen...
New
jaeyson
Hey! Just a random thought though: Found an article from fudzilla where AI can be a good debugger. How does one integrate something like ...
New
luigiluigiluigi
Hey everyone! :wave: We’re looking for a Back-End Developer Volunteer to help us build something impactful! If you want to gain real-wor...
New

Other popular topics Top

Devtalk
Hello Devtalk World! Please let us know a little about who you are and where you’re from :nerd_face:
New
ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
New
Margaret
Hello content creators! Happy new year. What tech topics do you think will be the focus of 2021? My vote for one topic is ethics in tech...
New
AstonJ
If you are experiencing Rails console using 100% CPU on your dev machine, then updating your development and test gems might fix the issu...
New
Maartz
Hi folks, I don’t know if I saw this here but, here’s a new programming language, called Roc Reminds me a bit of Elm and thus Haskell. ...
New
First poster: bot
The overengineered Solution to my Pigeon Problem. TL;DR: I built a wifi-equipped water gun to shoot the pigeons on my balcony, controlle...
New
New
CommunityNews
A Brief Review of the Minisforum V3 AMD Tablet. Update: I have created an awesome-minisforum-v3 GitHub repository to list information fo...
New
AstonJ
If you’re getting errors like this: psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory ...
New