我尝试通过 PowerShell 在单个 ps1 脚本中运行以下命令,希望两个本地服务器在不同端口上打开 - 仅打开 8080:
cd "\\blah\Statistics\Reporting\D3\walkthroughs\letsMakeABarChart"
python -m http.server 8080
cd "\\foo\data_science\20161002a_d3js\examples"
python -m http.server 8000
我可以调整它以便两者都打开吗?
最佳答案
第一个 python 调用可能不会返回,因此您可以使用 Start-Job
cmdlet:
$job1 = start-job -scriptblock {
cd "\\blah\Statistics\Reporting\D3\walkthroughs\letsMakeABarChart"
python -m http.server 8080
}
$job2 = start-job -scriptblock {
cd "\\foo\data_science\20161002a_d3js\examples"
python -m http.server 8000
}
# Wait until both web servers terminates:
Wait-Job -Job ($job1, $job2)
关于python - 通过一个 ps1 脚本打开两个网络服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39996792/