shell programming script commands

shell programming script commands

ssh login script

If we often log in to the linux system, we can use SCRT and xshell tools to manage them. These tools are charged. We can write a script by ourselves to facilitate login. For example, there are a group of servers with IPs: 192.168.3.11, 192.168.3.12,
192.168 .3.13  …

vim sshLogin.sh  自己写的一个ssh登录的shell加了判断条件

#!/bin/bash
if [ -n "$1" ];then
 ssh [email protected].$1
else 
 echo "please input ip number"
fi

chmod 777 sshLogin.sh is modified to executable permission./sshLogin.sh
11 Execution only needs to enter the last digit of ip

ssh script to log in using the public key key

vim sshLoginKey.sh

#!/bin/bash

#echo $1

ssh -i /home/liang//newkeys_aws [email protected].$1

chmod 764 sshLoginKey.sh Change to executable permission./sshLoginKey.sh
12 After execution with an ip parameter, you can dynamically enter ip to log in to ssh

Maven packages and automatically uploads server scripts

maven war package or jar package is sent to the shell on the environment

The premise is that you need to install maven environment variables

vim mavenPackageWar.sh
#! /bin/sh -

cd /home/liang/workspace/jtool

mvn clean install

cd /home/liang/workspace/war-dao

mvn clean install

cd /home/liang/workspace/war-service

mvn clean install

cd /home/liang/workspace/war-server

mvn clean package -Dmaven.test.skip=true

scp -i /home/liang/newkeys_aws /home/liang/workspace/war-server/target/ROOT.war [email protected]:/data/backup/shareDir/ROOT.war.`date +%Y%m%d%H%M` 

chmod 764 mavenPackageWar.sh modified to executable permissions

./mavenPackageWar.sh is executed on the premise that maven needs to be installed

shell upload or download files

ssh upload files to remote server or download files from remote server

http://blog.sina.com.cn/s/blog_7479f7990100zwkp.html

tar -zcvf /home/liang/aaa.tar.gz docker   打tar.gz包
tar -zcvf chat.tar.gz 404.html 50x.html css favicon.ico images info location mytest.html pic stat.xsd  打包多个文件或文件夹  

http://blog.itpub.net/28602568/viewspace-759523/

上传文件到远程服务器
scp -i /home/liang/newkeys_aws /home/liang/workspace/war-server/target/ROOT.war [email protected]:/data/backup/shareDir/ROOT.war.`date +%Y%m%d%H%M` 

scp -i /home/liang/newkeys_aws /home/liang/aa.html [email protected]:/data/backup/shareDir/aa.html

scp -i /home/liang/newkeys_aws_china -P 33890 /home/liang/bb.html [email protected]:/DISKC/appFile/bb.html


从远程服务器下载文件
cd  /home/liang/

scp -i newkeys_aws [email protected]:/data/aaa.tar.gz /home/liang/  

scp -i newkeys_aws [email protected]:/data/logs/gc_tomcat.log /home/liang/

scp -i newkeys_aws [email protected]:/DISKC/tmp/nginx.tar.gz /home/liang/

scp -i newkeys_aws -P 33890 [email protected]:/usr/local/openresty/nginx/conf/nginx.conf /home/liang/ 

scp -i newkeys_aws_china -P 33890 [email protected]:/DISKC/jswechat.tar.gz /home/liang/

http://syyming.blog.163.com/blog/static/232063520105241029991/
http://blog.chinaunix.net/uid-20545423-id-1930177.html

Reference link:
http://wiki.ubuntu.org.cn/Shell%E7%BC%96%E7%A8%8B%E5%9F%BA%E7%A1%80
http://www.cnblogs.com/ xuqiang/archive/2011/04/27/2031034.html
http://blog.csdn.net/sunboy8764/article/details/6892818
http://wenku.baidu.com/link?url=AWUheFzPaBv0WPxgh7f6Btcc8Si_CUH3lXEsy0qcC-lmr-W5BGwkQJHG779ev1zxEbjl7J3LmnG2OX3eH61ilEOzHnbDfJmT5SHuBgoRBka

Guess you like

Origin blog.csdn.net/yinjl123456/article/details/127891209