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

bot
A new item has been posted: https://crates.io/crates/rsfbclient This thread was posted automatically, if you feel it could be in a bett...
New
New
First poster: bot
AbstractMachinesLab/caramel. :candy: An Erlang backend to the OCaml compiler. Contribute to AbstractMachinesLab/caramel development by c...
New
CommunityNews
The Magic of Python Context Managers. Recipes for using and creating awesome Python context managers, that will make your code more read...
New
First poster: bot
About Self Self is a prototype-based dynamic object-oriented programming language, environment, and virtual machine centered around the p...
New
First poster: bot
https://twitter.com/briandfoy_perl/status/1354535622069919748 This thread was posted by one of our members via one of our news source tr...
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
Jsdr3398
I really need developers to help create my messaging platform but I’m not sure how much they want etc. I’ve never hired anyone before :s...
New
OvermindDL1
Woooooooo! This is such a huge release for it, and 2 years incoming! In short, the library is now using an updated hyper backend (not j...
New
mafinar
Hello folks! We had a pretty fun thread here around the same time last year - talking about Advent of Code problems. That also happened t...
New

Other popular topics Top

AstonJ
Or looking forward to? :nerd_face:
New
New
AstonJ
There’s a whole world of custom keycaps out there that I didn’t know existed! Check out all of our Keycaps threads here: https://forum....
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
PragmaticBookshelf
Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
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
AstonJ
Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New
foxtrottwist
A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
New
PragmaticBookshelf
Author Spotlight: Tammy Coron @Paradox927 Gaming, and writing games in particular, is about passion, vision, experience, and immersio...
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