Created
April 4, 2011 16:50
-
-
Save pklaus/901959 to your computer and use it in GitHub Desktop.
Automated test of the responses of a Koukaam NETIO230[A/B] device
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ####################################################################### | |
| # | |
| # Automated test of the responses of a Koukaam NETIO230[A/B] device | |
| # 2011-04-04 18-52 | |
| # | |
| ####################################################################### | |
| 100 HELLO 2F7BBC63 - KSHELL V1.2 | |
| login admin password | |
| 250 OK | |
| version | |
| 250 V 2.33 | |
| alias | |
| 250 Zarathustra | |
| port 1 | |
| 250 0 | |
| port list | |
| 250 0010 | |
| port wd 1 | |
| 250 disable 0.0.0.0 9 60 3 3 disable disable | |
| port setup 1 | |
| 250 "output_1" manual 5 0 | |
| email server | |
| 250 141.2.215.7 | |
| system discover | |
| 250 enable | |
| system swdelay | |
| 250 0 | |
| system sntp | |
| 250 disable de.pool.ntp.org | |
| system eth | |
| 250 manual 192.168.102.4 255.255.255.0 192.168.102.1 | |
| system dns | |
| 250 192.168.102.1 | |
| system time | |
| 250 2011/04/04,16:52:42 | |
| system timezone | |
| 250 0 | |
| uptime | |
| 250 0 years 1 days 5 hours 14 min 41 sec | |
| system kshport | |
| 250 1234 | |
| system webport | |
| 250 80 | |
| system dst | |
| 250 enabled 2011/04/06,06:10:10 - 2106/02/07,06:28:15 | |
| kshell | |
| 250 network | |
| port timer 1 t | |
| 250 once 00:00:00 00:00:00 0000000 | |
| port timer 1 dt | |
| 250 once 1970/01/01,00:00:00 1970/01/01,00:00:00 0000000 | |
| port timer 1 ux | |
| 250 once 00000000 00000000 0000000 | |
| quit | |
| 110 BYE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ####################################################################### | |
| # | |
| # Automated test of the responses of the NETIO230A fakeserver.py | |
| # 2011-04-09 23-45 | |
| # | |
| ####################################################################### | |
| 100 HELLO 9731D181 - KSHELL V1.2 | |
| login admin admin | |
| 250 OK | |
| version | |
| 250 V 2.33 | |
| alias | |
| 250 Zarathustra | |
| port 1 | |
| port list | |
| 250 0000 | |
| port wd 1 | |
| 502 UNKNOWN COMMAND | |
| port setup 1 | |
| 250 "outlet x" manual 5 0 | |
| email server | |
| 502 UNKNOWN COMMAND | |
| system discover | |
| 250 enable | |
| system swdelay | |
| 250 15 | |
| system sntp | |
| 502 UNKNOWN COMMAND | |
| system eth | |
| 502 UNKNOWN COMMAND | |
| system dns | |
| 502 UNKNOWN COMMAND | |
| system time | |
| 502 UNKNOWN COMMAND | |
| system timezone | |
| 502 UNKNOWN COMMAND | |
| uptime | |
| 502 UNKNOWN COMMAND | |
| system kshport | |
| 502 UNKNOWN COMMAND | |
| system webport | |
| 502 UNKNOWN COMMAND | |
| system dst | |
| 502 UNKNOWN COMMAND | |
| kshell | |
| 502 UNKNOWN COMMAND | |
| port timer 1 t | |
| 502 UNKNOWN COMMAND | |
| port timer 1 dt | |
| 502 UNKNOWN COMMAND | |
| port timer 1 ux | |
| 502 UNKNOWN COMMAND | |
| quit | |
| 110 BYE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version | |
| alias | |
| port 1 | |
| port list | |
| port wd 1 | |
| port setup 1 | |
| email server | |
| system discover | |
| system swdelay | |
| system sntp | |
| system eth | |
| system dns | |
| system time | |
| system timezone | |
| uptime | |
| system kshport | |
| system webport | |
| system dst | |
| kshell | |
| port timer 1 t | |
| port timer 1 dt | |
| port timer 1 ux | |
| quit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ## testKSHELL.sh - a script to automatically test Koukaam Netio230[a/b] devices | |
| ## | |
| ## This bash script was created by Philipp Klaus <philipp.l.klaus AT web.de>. | |
| ## Use this script to test your NETIO230[A/B] for strange behaviour or to compare | |
| ## the responses of the device between different firmware versions. | |
| ## This file is part of testKSHELL. | |
| ## | |
| ## testKSHELL is free software: you can redistribute it and/or modify | |
| ## it under the terms of the GNU General Public License as published by | |
| ## the Free Software Foundation, either version 3 of the License, or | |
| ## (at your option) any later version. | |
| ## | |
| ## testKSHELL is distributed in the hope that it will be useful, | |
| ## but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| ## GNU General Public License for more details. | |
| ## | |
| ## You should have received a copy of the GNU General Public License | |
| ## along with testKSHELL. If not, see <http://www.gnu.org/licenses/>. | |
| # default values (adopt them to your needs if you use the script regularly): | |
| DEF_ADDRESS="192.168.1.2" | |
| DEF_PORT="1234" | |
| DEF_PASSWORD="password" | |
| # Ask the user for connection details: | |
| echo -n "Enter the network address of the Koukaam NETIO-230A device and press [ENTER] (default: $DEF_ADDRESS): " | |
| read ADDRESS | |
| ADDRESS=${ADDRESS:-$DEF_ADDRESS} | |
| echo -n "Enter the tcp port of the Koukaam NETIO-230A device (1234 in default configuration) and press [ENTER] (default: $DEF_PORT): " | |
| read PORT | |
| PORT=${PORT:-$DEF_PORT} | |
| echo -n "Enter the password for the admin user of the Koukaam NETIO-230A device and press [ENTER] (default: $DEF_PASSWORD): " | |
| read PASSWORD | |
| PASSWORD=${PASSWORD:-$DEF_PASSWORD} | |
| # We need to wait some time for the device to send a response to our request. | |
| # I have tested the values 0.01 and 0.03 seconds with a direct 100Mbit link | |
| # and found them to be too little in some cases. I didn't have problems with 0.06 yet. | |
| SLEEPTIME="0.06" | |
| # print the header of the output file | |
| cat << EOF > output.txt | |
| ####################################################################### | |
| # | |
| # Automated test of the responses of a Koukaam NETIO230[A/B] device | |
| # $(date '+%Y-%m-%d %H-%M') | |
| # | |
| ####################################################################### | |
| EOF | |
| # We use the bash builtin TCP connection capabilities to create a TCP socket: | |
| exec 5<>/dev/tcp/${ADDRESS}/${PORT} | |
| # We run `cat` in the background (&) to record ALL responses to our requests. | |
| # (The option -u tells cat to write to the file without a buffer.) | |
| cat -u <&5 >> output.txt & | |
| cat_pid=$! | |
| sleep ${SLEEPTIME} | |
| # If the cat command already returned, then the connection failed: | |
| if ! kill -0 $cat_pid 2> /dev/null ; then | |
| echo -e "\nSorry, we cannot read from the tcp socket." | |
| echo -e "Either your connections details are wrong ($ADDRESS:$PORT) or the kshell server crashed.\n" | |
| rm output.txt | |
| exit 1 | |
| fi | |
| # Login to the NETIO230[A/B]: | |
| echo "login admin ${PASSWORD}" | tee -a output.txt >&5 | |
| sleep ${SLEEPTIME} | |
| # Woop through the lines of... | |
| while read line; do | |
| # send the command and write it to the output file: | |
| echo -e "${line}" | tee -a output.txt >&5 | |
| sleep ${SLEEPTIME} | |
| done < commands.txt # ... output.txt | |
| # at the end the background `cat` command should return: | |
| wait | |
| # now we rename the output file: | |
| newname="$(date '+%Y-%m-%d_%H-%M')_output.txt" | |
| mv output.txt "$newname" | |
| echo "Finished the automated interaction with the device." | |
| echo "The result log can be found on $newname" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment