Skip to content

Instantly share code, notes, and snippets.

View ChatchaiJ's full-sized avatar

Chatchai Jantaraprim ChatchaiJ

View GitHub Profile
@ChatchaiJ
ChatchaiJ / cert-check1.sh
Created September 25, 2017 08:16
Using openssl's s_client for printing certificates information from a web site
#!/bin/sh
[ -z "$1" ] && echo "Usage: $0 www.example.com" && exit
SERVERNAME="$1"
echo |\
openssl s_client \
-showcerts \
-servername $SERVERNAME \
#!/bin/bash
while true; do
date;
dig @8.8.8.8 ftp.coe.psu.ac.th +trace | egrep -v 'NSEC|RRSIG|DS|^\.|^th\.';
sleep 10;
done
#!/bin/sh
ssh-keygen -l -f ~/.ssh/id_rsa.pub |\
awk '{ print $2 }' |\
sed -e 's/://g' -e 's/^/key-hash ssh-rsa /' -e 's/$/ user@hostname/'
#!/bin/bash
CONF="${HOME}/.getcmd.conf"
[ ! -f "$CONF" ] && echo "No config file ${CONF}" && exit
source $CONF
[ -z "CMDSVR" ] && echo "CMDSVR is not defined" && exit
[ -z "CMDPATH" ] && echo "CMDPATH is not defined" && exit
[ -z "DONE" ] && echo "DONE is not defined" && exit
rm -f result.txt; cat ~/.passphrase | gpg --batch --passphrase-fd 0 result.txt.asc 2> /dev/null; echo $?
@ChatchaiJ
ChatchaiJ / pi-gputemp.sh
Created July 21, 2017 09:53
get raspberry pi GPU temperature
#!/bin/sh
sudo /opt/vc/bin/vcgencmd measure_temp | cut -f2 -d= | cut -f1 -d\'
@ChatchaiJ
ChatchaiJ / pi-cputemp.sh
Last active July 21, 2017 09:54
Get raspberry pi CPU temperature
#!/bin/bash
t=$(cat /sys/class/thermal/thermal_zone0/temp)
t1=$(expr $t / 1000)
t2=$(expr $t % 1000)
echo $t1.$t2
@ChatchaiJ
ChatchaiJ / wifi-scan
Created July 19, 2017 10:12
Scan WiFi using iwlist, get rid of those parts that we don't interested
#!/bin/sh
IFS=''
sudo iwlist wlan0 scanning |\
grep -E 'Quality|Cell|ESSID' |\
while read line; do
printf "%s" $line
ISESSID=`echo $line | grep ESSID`
[ "$ISESSID" ] && printf "\n"
done |\
@ChatchaiJ
ChatchaiJ / send-pi-wifi-scan
Created July 19, 2017 10:11
Send WiFi scan result as picture via Telegram message
#!/bin/sh
BINDIR="${HOME}/bin"
WORKDIR="/tmp/wifi"
WIFISCAN="$BINDIR/wifi-scan"
SENDPHOTO="$BINDIR/botSendPhoto"
TEXT2PNG="$BINDIR/text2png"
[ ! -d $WORKDIR ] && mkdir -p $WORKDIR
cd $WORKDIR || exit
@ChatchaiJ
ChatchaiJ / send-pi-screen
Created July 19, 2017 10:08
Using scrot to capture screen and send that screen capture image by Telegram bot
#!/bin/sh
BINDIR="${HOME}/bin"
WORKDIR="/tmp/capture"
SENDPHOTO="$BINDIR/botSendPhoto" # see botSendPhoto.sh script
## mode 777 is needed since we capture screen as 'pi' user
[ ! -d $WORKDIR ] && mkdir -m 0777 -p $WORKDIR
cd $WORKDIR || exit