OK - so I wrote a PowerShell script to keep my work RDP sessions from timing out - been using it a while - deciced to make a short cut to launch it (PowerShell is SO SO SO UGLY!) :
Clear-HostEcho “Keep alive w/ scroll lock…”$WShell = New-Object -com “Wscript.Shell”while ($true){$WShell.sendkeys(“{SCROLLLOCK}”)Start-Sleep -Milliseconds 100$WShell.sendkeys(“{SCROLLLOCK}”)Start-Sleep -Seconds 240}
And I got SICK of right clicking on it and “Run with PowerShell” so I created a shortcut :
Target : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File "%USERPROFILE%\Desktop\nodoze.ps1"
, and “Start in” of %USERPROFILE%\Desktop
… Oh so ugly (and I also learned, not that I tried it - but PowerShell can also use tilde “~” to represent “%USERPROFILE%”… SO UGLY… Anyway…
While I was there - decided to write a silly “keep alive” for my SSH sessions to remote hosts - I use MobaXterm on those Windows machines.
In Australia (and pretty sure in the UK too) you could ring a freecall number (it was #1194 in Au) and hear the talking clock man announce “…at the third stroke the time will be $HOUR $MINUTE and $SECONDS” - if it was going to hit a new minute on the third stroke, it would be “…at the third stroke the time will be $HOUR $MINUTE precisely”…
So - anyway - I only learned (today) that bash arithmetic treats numbers with a leading zero as octal - so if you need to convert to decimal you have to prefix 10#
on the variable that could potentially be treated as an octal number : TERD=$(( 10#$SS +3 ))
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────
│ File: talkyclockcrap.bash
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ #!/usr/bin/env bash
2 │ # the old cruddy talking clock #1194 :
3 │ while true
4 │ do
5 │ TIME=$(date '+%H:%M')
6 │ SS=$(date '+%S')
7 │ TERD=$(( 10#$SS +3 ))
8 │ echo "echo at da terd stroke it'll be $TIME($SS) and $TERD seconds approx..."
9 │ echo -e "pip" ; sleep 1
10 │ echo -e "\tpip" ; sleep 1
11 │ echo -e "\t\tpip" ; sleep 1
12 │ clear
13 │ done
───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────
And yeah - I’m too lazy to change it to correctly calculate where $SS and $TERD are =>57
…
and yeah - I always write naughty cuss words in my shell scripts
And yesterday I learned about $TMOUT variable - even if you’re root, you can’t change it in your current $ENV… I updated /etc/profile.d/timeout.sh - the default value was some UTTER CRAP like 10 minutes! WTF? This is on Red Hat Linux (EL) 8 :
cat /etc/profile.d/timeout.sh
readonly TMOUT=7200
export TMOUT
I think 7200 is two hours - which is pretty reasonable IMHO… but who decided on 10 f–king minutes (not this is not default on REL8 - someone [a colleague?] created a VMware template, and set $TMOUT to 10 minutes)?