Skip to content

Instantly share code, notes, and snippets.

View benwei's full-sized avatar

ben6 benwei

View GitHub Profile
@benwei
benwei / install_go_linux.sh
Last active April 5, 2020 07:09
simple script to install golang for Linux Debian or Ubuntu
#!/bin/sh
install_go_linux()
{
sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt update
sudo apt install -y golang-go
ret=$?
if [ $ret -eq 0 ]; then
go version
@benwei
benwei / list_iwnoise.sh
Created December 6, 2019 07:25
[busybox ash] List signal noise by while loop
i=0 ; while [ $i -lt 5 ] ; do iwconfig wlan0 | grep Noise ; sleep 1 ; i=$((i+1)) ; done
@benwei
benwei / run_iperf_once_a_hour.sh
Created December 6, 2019 01:42
a testing ash script for iperf periodically
#!/bin/sh
IP=$1
if [ "x$IP" = x ]; then
echo "syntax: <ServerIP>"
exit 1
fi
PERIOD=3600
BITS=5M
run_batch_iperf()
@benwei
benwei / Example to run script
Last active November 13, 2019 12:24
python script convert string to hex as echo -e command, tested with python 2.7 and 3.5
~$ python2.7 str_to_hex_for_echo_cmd.py
echo -e "testecho_\x21#\x24%\x2a\x5c'\x5c\x22\x21~?<>\x3a| 89920."
~$ python3.5 str_to_hex_for_echo_cmd.py
echo -e "testecho_\x21#\x24%\x2a\x5c'\x5c\x22\x21~?<>\x3a| 89920."
~$ echo -e "testecho_\x21#\x24%\x2a\x5c'\x5c\x22\x21~?<>\x3a| 89920."
testecho_!#$%*\'\"!~?<>:| 89920.
@benwei
benwei / start.sh
Last active November 14, 2019 08:24
Logging CPU load by top command per minute with BusyBox command environment
#!/bin/sh
## if you want to run toplog_per_minute.sh in background
## you have to use leading script to put it into backgroud without
## issue of "Stopped (tty output)" Error Message of script that
## stucked on busybox top command
## tested in BusyBox v1.20.2
##################################################################
/bin/sh /mnt/nand/toplog_per_minute.sh &
@benwei
benwei / test_result_on_linux_01-abspath-mk
Last active March 21, 2019 14:03
test result of 01-abspath-mk.mk
/build$ make -v
GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
/build$ lsb_release -a
No LSB modules are available.
current_mk_abspathname := $(abspath $(lastword $(MAKEFILE_LIST)))
current_mk_absdir := $(dir $(current_mk_abspathname))
all:
@echo "Makefile absolute pathname: $(current_mk_abspathname)" ; \
echo "Makefile absolute path: $(current_mk_absdir)"
@benwei
benwei / yaml_test1.py
Last active March 14, 2019 16:25
test to load yaml syntax by pyyaml library
import yaml
document = """
a: 1
b:
c: 3
#!/bin/bash
i=1
while [ ! "x$1" = "x" ]; do
echo "argv[$i]=[$1]"
shift
i=$((i + 1))
done
@benwei
benwei / test-cases.sh
Last active March 14, 2019 16:38
run remote cases by ssh with multiple arguments using shell - https://ben6.blogspot.com/2019/03/run-command-with-multiple-arguments.html
#/bin/bash
# 2019 Ben Wei <ben@juluos.org>
#
# This is a example script for CI tests for blog
# if not defined in environment variable
# you can use the following command to defined it
#
# export TEST_SSH_HOST="your_ssh_host"