osx - run Terminal script that executes one command and while that command is running, opens a new tab and runs another command -


at moment making java application. test have run server , client.

so want run using bash script:

#!/bin/bash clear gradle runserver osascript -e 'tell application "terminal" activate' -e 'tell application "system events" tell process "terminal" keystroke "t" using command down' gradle runclient 

problem: server when run does not end until close game, next 2 commands will not execute. how can run them concurrently/simultaneously ?

run server in background, kill when script done.

here’s example simple http server , client.

#!/bin/bash  date > foo.txt python -m simplehttpserver 1234 & server_pid="${!}" # automatically terminate server on script exit trap 'kill "${server_pid}"' 0 1 2 3 15  # wait server start while ! netstat -an -f inet | grep -q '\.1234 ';     sleep 0.05 done  # run client curl -s http://localhost:1234/foo.txt 

running in tab gets lot trickier; interleaves output client , server.

$ ./doit.sh 127.0.0.1 - - [19/sep/2014 23:00:32] "get /foo.txt http/1.1" 200 - fri 19 sep 2014 23:00:32 mdt 

note log output http server, , output http client. server automatically killed afterwards.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -