Tag: bash
openssl encrypt decrypt script | password handling
Add -pass pass:YOURPASS as an argument.
NAGIOS | poor mans report scripting
You wanna report some stuff to nagios the easy way? Try this. Nagios server side: Install netcat. Run a eternal loop script: # while true; do nc -l -p <THE_PORT_YOU_WANNA_LISTEN_TO> >> /var/nagios/rw/nagios.cmd; done& Client side: Install netcat. Drop your info to the NAGIOS server with something like: # echo -e “[$(date +%s)] PROCESS_SERVICE_CHECK_RESULT;<NAGIOSCONFIG_SERVER_NAME>;<NAGIOSCONFIG_SERVICE_NAME>;<RESULT_0_or_1_or_2>;<YOUR_IMPORTANT_MESSAGE>” | nc […]
TELEGRAM | telegram-cli | some hints
always use the -W parameter, otherwise you will earn an error (38: can not parse arg #1) that means your peer is unknown afaik its impossible to send strings to stdin address clients/channels whos name contain spaces by their id (user#1234567890 or channel#1234567890) use the -I and -N parameters still problematic? try https://bytesandbones.wordpress.com/2021/11/03/telegram-channel-linux-console-scripting-setup/
Bash | split a string into an array
ARRAY=(${STRING//,/ }) Dont forget the space character after the last slash.
Chop leading or trailing whitespaces in scripts
pipe it to xargs stdin
Summertime or not
function isSummerTime(){ if perl -e ‘exit ((localtime)[8])’ ; then return 1 fi return 0 }
linux | get system idle via script
# XX=5;top -n $XX | grep CPU | grep id | awk ‘{print $8}’ | awk ‘{s+=$1} END {print s}’ | xargs -I % echo “scale=0;%/$XX” | bc -l
You must be logged in to post a comment.