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

原创文章请随便转载。愿和大家分享,并且一起进步。– 江 coder

Original: https://www.cnblogs.com/jiangxiaobo/p/14153334.html
Author: jiangxiaobo
Title: linux shell和windows bat编写

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/8600/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

免费咨询
免费咨询
扫码关注
扫码关注
联系站长

站长Johngo!

大数据和算法重度研究者!

持续产出大数据、算法、LeetCode干货,以及业界好资源!

2022012703491714

微信来撩,免费咨询:xiaozhu_tec

分享本页
返回顶部