#!/usr/local/bin/zsh #------------------- runall ------------------ # z-shell script to automatically launch 6 robots # with appropriate parameters. # First argument: 'd' or 'a' for disperse or aggregate # Second argument: port that the communication server is running on if [ $ARGC -ne 2 ] then echo "Usage: \n'runall d [portnum]' for disperse behavior.\n'runall a [portnum]' for aggregate behavior.\n\n[portnum] = the port number that communication_server is running on.\n\n" exit 1 fi echo "NOTE: Press Ctrl-d or Ctrl-c to stop all the robots.\n" if [ "$1" = "d" ] then foreach x in `seq 1 6`: ./hw2 d 1400 1400 1000 -portc $2 $x & end fi if [ "$1" = "a" ] then foreach x in `seq 1 6`: ./hw2 a 1400 1400 700 -portc $2 $x & end fi ### wait for user to press ctrl-d to end robot simulation #(trap ctrl-c so it will do the same thing rather than killing script) trap "" INT `cat` echo "\ncleaning up" pkill -u $LOGNAME hw2