BE_reseau/tsock_texte

42 lines
800 B
Text
Raw Permalink Normal View History

2016-06-13 23:17:19 +02:00
#!/bin/bash
puits=false
sourc=false
dest="127.0.0.1"
2016-06-13 23:17:19 +02:00
usage() { echo "Usage: $0 [-p|-s destination] port" 1>&2; exit 1; }
2016-06-13 23:17:19 +02:00
while getopts "ps:" o; do
case "${o}" in
p)
puits=true
;;
s)
sourc=true
dest=${OPTARG}
;;
*)
usage
;;
esac
2016-06-13 23:17:19 +02:00
done
if (([ "$sourc" = true ] && [ $# -ne 3 ]) || ([ "$puits" = true ] && [ $# -ne 2 ])) || (([ "$puits" = true ] && [ "$sourc" = true ]) || ([ "$puits" = false ] && [ "$sourc" = false ])) ; then
usage
exit 1
2016-06-13 23:17:19 +02:00
fi
port=${@: -1}
2016-06-13 23:17:19 +02:00
if [ "$puits" = true ]; then
cd build
./server $port
2016-06-13 23:17:19 +02:00
cd ..
fi
if [ "$sourc" = true ]; then
cd build
./client $dest $port
2016-06-13 23:17:19 +02:00
cd ..
fi