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
New
pillaiindu
I have heard many times that languages with a garbage collector aren’t great for system programming. Today I saw a book titled “Hands-On ...
New
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
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
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
New
DevotionGeo
What do you people do for reading Erlang docs? Is there something like Ruby’s ri? I installed manual pages for Erlang under /usr/local/...
New
Cellane
Phoenix 1.6.0 got released last week, with built-in authentication and mailer generators, a whole new HEEx (HTML-aware Embedded Elixir) e...
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
AstonJ
Or looking forward to? :nerd_face:
New
New
gagan7995
API 4 Path: /user/following/ Method: GET Description: Returns the list of all names of people whom the user follows Response [ { ...
New
PragmaticBookshelf
Build efficient applications that exploit the unique benefits of a pure functional language, learning from an engineer who uses Haskell t...
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
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
New
New