Reputation: 30681
I am trying to write a shell script that launches a server and then fires up a browser to view the served content
(cd app && python -m SimpleHTTPServer) &
open http://localhost:8000
Disclaimer: I'm new to bash scripting and I don't really know python.
It seems that when adding the &
operator at the end of the line, the process doesn't stay alive long enough to remain functional.
What am I doing wrong?
Upvotes: 2
Views: 1987
Reputation: 241701
The problem is (probably) not that the server doesn't stay alive long enough; it's that it doesn't start up fast enough. When the open
command executes, the webserver hasn't started yet, so you get an error.
Try sleeping for a second or two before the open
Upvotes: 1