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.

Where Next?

Popular Backend topics Top

AstonJ
I’ve seen more and more people get into Rust recently, so thought it would be cool to have a thread for people to share what they like ab...
New
New
New
AstonJ
Consider this Erlang code: Rectangle = {rectangle, 20, 10}. {rectangle, Width, Height} = Rectangle. > Width. 20 > Height. 10 When...
New
DevotionGeo
How Dgraph was running out of memory for some users, and how Go’s Garbage collector wasn’t enough, and Dgraph team used jemalloc to manag...
New
finner
During a recent code review I came across this scenario: Code in review if (input.getValue() != null) { return Arrays.asList(value);...
New
mafinar
I wrote a blog post! On F#. I usually don’t write things but figured i should try it out, also experimenting with F# and C# lately, love ...
New
KnowledgeIsPower
MongoDB, Cassandra, DynamoDB and etc. Also, do you use VM or container to run it?
New
lucasvegi
Hello guys! Perhaps some of you have already seen this invitation on other channels in the Elixir community or even responded to our sur...
New
apoorv-2204
Hi everyone, I’m considering pursuing the Elixir/Erlang certification exam offered by Erlang Solutions and wanted to check in with the c...
New

Other popular topics Top

AstonJ
A thread that every forum needs! Simply post a link to a track on YouTube (or SoundCloud or Vimeo amongst others!) on a separate line an...
New
New
AstonJ
Curious to know which languages and frameworks you’re all thinking about learning next :upside_down_face: Perhaps if there’s enough peop...
New
AstonJ
I ended up cancelling my Moonlander order as I think it’s just going to be a bit too bulky for me. I think the Planck and the Preonic (o...
New
AstonJ
I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl: The Ser...
New
PragmaticBookshelf
“A Mystical Experience” Hero’s Journey with Paolo Perrotta @nusco Ever wonder how authoring books compares to writing articles?...
New
DevotionGeo
The V Programming Language Simple language for building maintainable programs V is already mentioned couple of times in the forum, but I...
New
wmnnd
Here’s the story how one of the world’s first production deployments of LiveView came to be - and how trying to improve it almost caused ...
New
First poster: bot
Large Language Models like ChatGPT say The Darnedest Things. The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
New
First poster: bot
zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig. General-purpose programming language and toolchain for maintaini...
New
OSZAR »