2021-12-17
time synchronization script
fedora version upgrade in-place
2021-12-06
AutoHotKey script to find mouse coordinates
#Warn ; Recommended for catching common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; While CapsLock is toggled On
; Script will display Mouse Position (coordinates) as a tooltip at Top-Left corner of screen.
; Also allows to copy them (to clipboard) with a PrintScreen button.
#SingleInstance force ; only one instance of script can run
#Persistent ; to make it run indefinitely
settimer start1, 0 ; "0" to make it update position instantly
return
start1:
if !GetKeyState("capslock","T") ; whether capslock is on or off
{
tooltip ; if off, don't show tooltip at all.
}
else
{ ; if on
CoordMode, ToolTip, Screen ; makes tooltip to appear at position, relative to screen.
CoordMode, Mouse, Screen ; makes mouse coordinates to be relative to screen.
MouseGetPos xx, yy ; get mouse x and y position, store as %xx% and %yy%
tooltip %xx% %yy%, 0, 0 ; display tooltip of %xx% %yy% at coordinates x0 y0.
PrintScreen:: ; assign new function to PrintScreen. If pressed...
clipboard == %xx% %yy% ; ...store %xx% %yy% to clipboard.
return
}
return
Autohotkey is your WIndows superpower
Autohotkey (AHK) is a Windows programming macro application to click the mouse or repeat keystrokes to your heart's content. I just wrote this 6-line program to click "GO LIVE" button in Youtube, launched by Windows (Task) Scheduler at a particular time, because we kept forgetting to click the "GO LIVE" to begin our livestreams. It is actually setup "in case you forgot" as "GO LIVE" becomes "END LIVESTREAM".
The mouse coordinates are particular to the computer it was intended for and may not match your computer.
(Find mouse coordinates with this script: https://www.bachcottage.com/2021/12/autohotkey-script-to-find-mouse.html )
#WinActivateForce
WinActivate, Live streaming - YouTube Studio,
sleep 300
WinMaximize, Live streaming - YouTube Studio,
sleep 6000
mouseclick Left,1803,96
sleep 3000
mouseclick Left,1600,96
AutoHotKey |
2021-12-03
A simple script to get and file the Internet WAN IP address of your private network
xip=`/usr/bin/wget -q --read-timeout=15.0 --waitretry=5 --tries=3 http://checkip.dyndns.org -O - | /usr/bin/cut -f2 -d: | /usr/bin/cut -f1 -d"<" | /usr/bin/sed "s/\ //g"`
/usr/bin/echo $xip | /usr/bin/egrep -q [0-9,\.] && {
/usr/bin/echo /usr/bin/egrep -q $xip$ /local/etc/wanip.txt
/usr/bin/echo -n "grep response: "
/usr/bin/egrep $xip$ /local/etc/wanip.txt
/usr/bin/egrep -q $xip$ /local/etc/wanip.txt || {
/usr/bin/wall $HOSTNAME wan IP changes $xip
/usr/local/etc/pushovermsg $HOSTNAME wan IP changes $xip
}
/usr/bin/echo $xip > /local/etc/wanip.txt
} || {
/usr/bin/echo IP found was: $xip
/usr/bin/echo no ip acquired
}
Linux - forwarding IP traffic while masquerading the source IP address
# the script arguments are:
# $1 is "I" for insert the masquerade in the table before all other iptables enteries
# $2 is the source IP address to be masqueraded be it a specific address "10.11.11.3" or "10.11.11.0/24"
# this is particularly useful for openvpn connections
/usr/sbin/sysctl -w net.ipv4.ip_forward=1
/usr/sbin/sysctl -w net.ipv6.conf.all.forwarding=1
iptables --table nat -$1 POSTROUTING -s $2 -j MASQUERADE
Linux - my favorite aliases to put in a shell profile
set -o vi
alias less="less -X"
alias dnf="dnf -y "
alias df="df -h "
alias le="cd /local/etc"
alias e="cd /etc"
alias esn="cd /etc/sysconfig/network-scripts"
alias ens="cd /etc/NetworkManager/system-connections"
alias etd="cd /etc/dhcp"
alias eo="cd /etc/openvpn"
alias ess="cd /etc/systemd/system"
alias en="cd /etc/NetworkManager"
alias vl="cd /var/log"
alias pu="pushd "
alias po="popd"
alias d="dirs -v"
alias pp="pushd || popd"
alias lo="lsof -n -i -P"
alias lsdir="ls -d */"
PS1="\h \D{%F %T} \w \$ "
alias lsof="lsof -i -n -P "
2021-12-02
perl script to wait for a command "wait4cmd" that appears in the process table of Linux
# This part checks to see if the process is already running
$xcmd = join(" ",@ARGV);
die "No command to wait.\n" if ($xcmd eq "");
if (0) {
if (open(PS, "/usr/bin/ps ax | /usr/bin/grep \"wait4cmd $xcmd\" | /usr/bin/grep -v grep |")) {
@psax = <PS>;
close(PS);
for(@psax) {
s/^\s+//g;
if (/wait4cmd $xcmd/) {
#print "$_";
($pid, @stuff) = split(/\s+/);
#print "$$ pid is $pid and $stuff[0]\n";
if ($pid != $$) {
die "$xcmd already being waited on\n";
# no reason to run if already doing this
}
}
}
}
} # skipped for now bracket
# deal with stdin, stdout, stderr, control terminal, and fork
if (0) {
$TIOCNOTTY = 0x20007471;
close(stdin);
open(stdout, ">/dev/null");
open(stderr, ">/dev/null");
if (open(tty, "/dev/tty")) {
ioctl(tty, $TIOCNOTTY, 0);
close(tty);
}
}
# infinite loop begins here to search for a command
while (1) {
@reply=`$xcmd`;
$strreply=join ' ',@reply;
last if ($strreply =~ /[a-z,A-Z,1-9]/);
sleep(10);
}
print "End\n";
$DATE = `/bin/date +'%Y-%m-%d-%H-%M'`;
system("/usr/bin/logger -p local1.emerg wait4cmd $strreply $DATE ");
system("/usr/bin/wall wait4cmd $strreply ");
Script to see network interface connection speed
cat network-speed #!/usr/bin/bash # ethtool enp2s0 | grep Speed ethtool $1 | grep Speed # mii-tool -v enp2s0 mii-tool -v $1 network-speed ...
-
This script with it's two related configuration files worked on Raspberry Pi Raspbian Linux. What was always sketchy was the "dri...
-
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. #Warn ; Recommended for catching common errors. Send...
-
cat network-speed #!/usr/bin/bash # ethtool enp2s0 | grep Speed ethtool $1 | grep Speed # mii-tool -v enp2s0 mii-tool -v $1 network-speed ...