I think this is related to: How can I check if a program exists from a Bash script?
Specifically, I want to run py -m http.server
on computers that have py
but don't have python3
and I want to run python3 -m http.server
on computers that have python3
but not py
. I also tried just checking the version number: py -v && py -m http.server; python3 -v && python3 -m http.server
but this still seems to have the same problem, and hitting ctrl+C twenty times doesn't kill it.
I tried py && py -m http.server; python3 && python3 -m http.server
but I believe it's executing the second command within python. Also, there are other aliases for Python on other computers. I know that I could just set py
as an alias for python3
, but I'm looking for a universal solution.
(Side note: It really bothers me that this is inconsistent. They should all just work.)
Eventually, I want a script that runs two things in parallel: the first is just npm run dev
which has a --watch
on it and has to continue to run, and the other is to cd docs/
then use python to host on localhost, then open chrome to localhost:8000
, additional help would be much appreciated, still a beginner to Linux.
I also want to make a second command that runs npm run build
, changes the second line in docs/sw.js from const dynamicCacheName = 'site-dynamic-vNUMBER';
to replace NUMBER with NUMBER+1.