문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top