• Check it out - we have a chatbot! Go ask TuxBot a question in the Ask Tuxbot section!

Linux.org User-created Helpful Shell Scripts::Meta Discussion/Chat

Fanboi

Well-Known Member
Joined
Apr 16, 2021
Messages
499
Reaction score
409
Credits
6,114
This pertains to this thread by the same name. Because this forum tends to get lost in digressions -- and full disclosure: I'm one of the biggest offenders -- I thought I'd make a space for meta chat since, as @KGIII rightfully instructed in his thread:
Other than specific questions regarding existing scripts, let's *try* to keep things on-topic.

Now what I suggest is:
If you have a question that's indirect, say, "How do I label my ssd?" when it's a copy/backup script, then @ the user here and link to his/her script with the question rather.

I think that's fair, yes? Also, I'm sure we can move the existing off-topic posts here, too. Let's try to keep that thread clean. ;)

- J
 


OP
Fanboi

Fanboi

Well-Known Member
Joined
Apr 16, 2021
Messages
499
Reaction score
409
Credits
6,114
@captain-sensible
python is technically a scripted language can we mention those ?
what about php ?
I would imagine that perl, awk, python, ruby, etc. are all allowed within the context of what can be run as a shell script or embedded in one. I mean bash is executed within a "shell script", as are several languages/executables. I think the best way to look at it is: "Will the entire thing run in the CLI?"
 
OP
Fanboi

Fanboi

Well-Known Member
Joined
Apr 16, 2021
Messages
499
Reaction score
409
Credits
6,114

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
654
Reaction score
529
Credits
3,683
This script isn't mine, I didn't write it. An acquaintance of mine wrote it for me to check for a certain nvidia driver version in Arch repo but it can be used for anything similar, if you change the URL address.

Code:
#!/bin/bash
while [ 0 -eq 0 ]
do
    CHECK="$(curl -s https://archlinux.org/packages/extra/x86_64/nvidia-dkms/ | grep '<h2>nvidia-dkms')"
    CHECK2="$(echo $CHECK | sed 's/<h2>//g' | sed 's/<\/h2>//g')"
    CHECK3="$(echo $CHECK2 | wc -m)"
    if [ $CHECK3 -ge 21 ]
    then
            echo "$CHECK2, I'll check again in a week."
    else
            zenity --info --text "NVIDIA-DKMS stable driver is available\n<b>$CHECK2</b>" --width="400" --title="NVIDIA DKMS driver check"
    fi
    sleep 604800
done

The reason I needed this script is because nvidia seems to be pushing mostly beta drivers on linux users (XXX.XX.XX) which don't support some things like NVENC. So instead of checking every week whether they have released a stable driver, I rely on the script to do the check for me and if such a driver is available, it will show me a zenity window with a message. If no stable driver is available, it will show nothing.
Initially the script was for the regular version but then I realized the DKMS edition is much more useful (bc it performs 'mkinitcpio -p linux' on its own for both linux and linux-lts), so I changed the script to check for the DKMS edition.
The way he explained it to me - the script checks if the package name has less than 21 characters. If it has less than 21, then that's a stable driver (for instance: nvidia-dkms 515.57-1). If exactly 21 or more, that's the unwanted by me beta driver (nvidia-dkms 515.65.01-1).
 
MALIBAL Linux Laptops

Linux Laptops Custom Built for You
MALIBAL is an innovative computer manufacturer that produces high-performance, custom laptops for Linux.

For more info, visit: https://www.malibal.com

Staff online

Members online


Top