shell script 学习
来源:互联网 发布:mysql多表联合查询 编辑:程序博客网 时间:2024/05/16 11:08
shell script
现在跟服务器打交道基本就这些
打包,上传,部署
重服务器拉指定文件下来
查看指定日志
其实很多重复的东西,何不学学写脚本。。
1.my first script
#!/bin/bash # desc - scp # anthor - wangjia_yql@qq.com # time - 2016-05-07 16:41 #romote param config REMOTE_USER_NAME='root' REMOTE_IP='123.59.61.216' REMOTE_PATH='~/inout/war' #my pc war_path MY_PATH='/Users/wangjia/java/test_data/testwar' read -p "enter the file's full name :" WAR_NAME FILE_PATH=${MY_PATH}/${WAR_NAME} if [ ! -f ${FILE_PATH} ]; then echo " - file - >" ${FILE_PATH} echo " - - not exist - - check it!!" exit 0 fi #set -x 打印执行的脚本 # scp ${MY_PATH}/${WAR_NAME} ${REMOTE_USER_NAME}@${REMOTE_IP}:${REMOTE_PATH} if [ $? -eq 0 ] then echo ' - - success - -' fi #end
上面是一个非常简单的scp上传脚本,简单的说一下。
首先是设置下相关参数,这里有个REMOTE_PATH和MY_PATH,分别是服务器和本机的出入口。
设置这个东西,基本是为了方便所有的需要上传到服务器或者从服务器down下来的文件,都必须经过这个文件夹。
两台机器之间有统一个出入口,方便拿取文件。
该文件夹路径不变,方便后续order,要是不统一,也没办法写脚本了判断文件是否存在,存在上传到服务器,不存在提示。
第一个脚本总结
- 了解相关语法
- echo; 参数;变量;简单判断;循环;exit code;
0 0
- Shell Script 的学习
- 学习Shell script
- shell script学习备忘
- 学习shell script
- 学习 shell script
- Shell Script 学习整理
- shell script 学习
- 学习shell script
- Linux shell script学习
- 学习shell script
- shell script 学习记录
- Shell Script 学习笔记
- 学习shell script
- Day4:学习shell script
- 学习shell script
- shell script学习
- Linux的Shell Script学习
- shell script学习笔记1
- 安卓学习记录03
- 一个屌丝程序猿的人生(五)
- cocos2d-x游戏开发实例(一)
- iOS 星星评分评分控件
- which命令
- shell script 学习
- ACM--模拟––湘大OJ 1144--Echo--水
- Yii-Unable to verify your data submission 错误(CSRF)
- 常见计算机英文汇总
- 金旭亮老师:“智商平平”学软件
- 最详细的Log4j使用教程
- android热修复原理总结
- Python字符串操作汇总
- [Hash] [最短路] [Vijos P1184] CoVH之华丽的IP伪装 (ConanIP)