linux shell和windows bat编写

windows

@echo off
setlocal enabledelayedexpansion
for /f "tokens=1-5" %%a in ('netstat -ano ^| find ":5500"') do (
if "%%e%" == "" (
    set pid=%%d
      ) else (
        set pid=%%e
     )
   echo !pid!
   taskkill /f /pid !pid!
)
pause
set NODE_ENV=dev
gulp build

关闭端口来源于:

@echo off
setlocal enabledelayedexpansion
set /p port=please input port number:
for /f "tokens=1-5" %%a in ('netstat -ano ^| find ":%port%"') do (
if "%%e%" == "" (
    set pid=%%d
      ) else (
        set pid=%%e
     )
   echo !pid!
   taskkill /f /pid !pid!
)
pause

 

 

linux shell

#!/bin/bash
echo "准备清扫"
/usr/bin/docker stop payment_h5_business && /usr/bin/docker rm payment_h5_business
sleep 1
echo "清扫完毕"
echo "准备建立"
/usr/bin/docker build -t payment_h5_business:demo .
sleep 1
echo "建立完毕"
echo "准备运行"
if [ $1 == "-d" ]
then
  /usr/bin/docker run -d -p 8080:80 --name=payment_h5_business payment_h5_business:demo
else
  /usr/bin/docker run -p 8080:80 --name=payment_h5_business payment_h5_business:demo
fi
echo "运行完毕"


# 如何执行
# chmod +x ./start.sh 给予可执行权限
# ./start.sh -d
# ./start.sh

 

posted @ 2020-12-18 09:30  jiangxiaobo  阅读(350)  评论(0编辑  收藏  举报