diff --git a/SCR/SCR1.2/TP08/bin2dot-with-for.sh b/SCR/SCR1.2/TP08/bin2dot-with-for.sh index e61def4..0f5f77c 100755 --- a/SCR/SCR1.2/TP08/bin2dot-with-for.sh +++ b/SCR/SCR1.2/TP08/bin2dot-with-for.sh @@ -17,8 +17,8 @@ for line in $(cat $1); do l1=$(expr substr $line 1 8) l2=$(expr substr $line 9 8) - l3=$(expr substr $line 18 8) - l4=$(expr substr $line 26 8) + l3=$(expr substr $line 17 8) + l4=$(expr substr $line 25 8) echo "$((2#$l1)).$((2#$l2)).$((2#$l3)).$((2#$l4))" >>$2 diff --git a/SCR/SCR1.2/TP08/bin2dot-with-read.sh b/SCR/SCR1.2/TP08/bin2dot-with-read.sh new file mode 100644 index 0000000..b0d8af4 --- /dev/null +++ b/SCR/SCR1.2/TP08/bin2dot-with-read.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +if [[ $# -lt 2 ]]; then + echo "usage: $0 " + exit 1 +fi +if [[ -s $2 ]]; then + read -p "$2 exists. Overwrite? Yes/No --> " -r choice + if [[ $choice = "Yes" ]]; then + echo "overwriting $2 !" + echo -n "" >$2 + fi +fi + +while [[ ]]; do + if [[ $(expr length $line) -eq 32 ]]; then + + l1=$(expr substr $line 1 8) + l2=$(expr substr $line 9 8) + l3=$(expr substr $line 17 8) + l4=$(expr substr $line 25 8) + + echo "$((2#$l1)).$((2#$l2)).$((2#$l3)).$((2#$l4))" >>$2 + + else + echo "Invalid format for : $line the string isn't 32bits long" + fi + +done diff --git a/SCR/SCR1.2/TP08/ipv4.txt b/SCR/SCR1.2/TP08/ipv4.txt index 1447002..b1d26ab 100644 --- a/SCR/SCR1.2/TP08/ipv4.txt +++ b/SCR/SCR1.2/TP08/ipv4.txt @@ -1,3 +1,3 @@ -178.226.14.114 -229.197.178.82 -50.230.8.114 +178.226.135.114 +229.197.89.82 +50.230.132.114