echo

拨测ip+port 告警 telnet nc

江枫思渺然 提交于 2020-01-09 16:47:19
1.telnet [root@master-node156 mon_port]# cat mycheck_port|egrep -v '^$' #! /bin/sh #企业微信警配置 alert=True #配置True为启动告警,其它为不开启 #企业微信机器人ID userkey="5642127c-woab-shib-9da8-ac2f4adashabic003" echo 'a' >/tmp/problemip.txt cur_datetime=`date +%Y%m%d-%H:%M:%S` homeDir=`dirname $0` function check_port { pkill -9 telnet timeout 2 ssh 127.0.0.1 telnet $1 >/tmp/a.txt myresult=`egrep -i 'Escape' /tmp/a.txt|wc -l` if [[ $myresult -eq 1 ]];then echo "$cur_datetime 端口$port listening,status is ok..." | tee -a $homeDir/port_status.log else echo "$cur_datetime Error 端口$port closed,status is failed..." | tee -a

如何从另一个Shell脚本调用Shell脚本?

萝らか妹 提交于 2020-01-09 16:46:14
我有两个 shell 脚本 a.sh 和 b.sh 。 我怎么能叫 b.sh 从shell脚本中 a.sh ? #1楼 看一下这个。 #!/bin/ bash echo "This script is about to run another script." sh ./script.sh echo "This script has just run another script." #2楼 pathToShell="/home/praveen/" chmod a+x $pathToShell"myShell.sh" sh $pathToShell"myShell.sh" #3楼 您可以使用 /bin/sh 调用或执行另一个脚本(通过您的实际脚本): # cat showdate.sh #!/bin/bash echo "Date is: `date`" # cat mainscript.sh #!/bin/bash echo "You are login as: `whoami`" echo "`/bin/sh ./showdate.sh`" # exact path for the script file 输出为: # ./mainscript.sh You are login as: root Date is: Thu Oct 17 02:56:36 EDT 2013 #4楼

update

假装没事ソ 提交于 2020-01-09 16:45:48
<?php if (empty($_GET['id'])) { exit('没有接收到id'); } $id=$_GET['id']; $conn=mysqli_connect('127.0.0.1','root','123456','demo'); if (!$conn){ exit('没有连接到数据库'); } $data=mysqli_query($conn,"select * from users where id={$id} limit 1;"); if (empty($data)){ exit('查找不成功');} $user = mysqli_fetch_assoc($data);//关联数组 var_dump($user); if (empty($user)){ exit('没有数据'); } function update(){ global $user; if (empty($_POST['name'])){ $GLOBALS['err_message']='请输入姓名'; return; } if($_POST['gender']==='-1'&&empty($_POST['gender'])){ $GLOBALS['err_message']='请选择性别'; return; } $user['name']=$_POST['name']; $user[

How to echo multi lined strings in a Bourne shell [duplicate]

蓝咒 提交于 2020-01-09 10:38:43
问题 This question already has answers here : When to wrap quotes around a shell variable? (5 answers) Closed 4 years ago . I want to create some scripts for filling some templates and inserting them into my project folder. I want to use a shell script for this, and the templates are very small so I want to embed them in the shell script. The problem is that echo seems to ignore the line breaks in my string. Either that, or the string doesn't contain line breaks to begin with. Here is an example:

PHP调用全国天气预报数据接口查询天气

谁说我不能喝 提交于 2020-01-09 03:57:05
基于PHP的聚合数据全国天气预报API服务请求的代码样例 本代码示例是基于PHP的聚合数据全国天气预报API服务请求的代码样例,使用前你需要: ①:通过https://www.juhe.cn/docs/api/id/39 申请一个天气预报API的appkey 样例代码包含了获取支持城市列表、根据城市获取天气预报、根据IP地址请求天气预报、根据GPS坐标请求天气、城市3小时天气预报的实现。示例代码主要是解析一些常用字段,如需要完整或其他未包含的字段,可以自行参考官方的接口,进行修改。 首先:引入封装好的天气调用类 header('Content-type:text/html;charset=utf-8'); include 'class.juhe.weather.php'; //引入天气请求类 //接口基本信息配置 $appkey = '**********'; //您申请的天气查询appkey $weather = new weather($appkey); 一、获取支持的城市列表 由于支持的城市列表基本不会这么变化,大家可以获取到列表后内置到自己的应用中,就不用每次都去请求API。 $citysResult = $weather->getCitys(); if($citysResult['error_code'] == 0){ //以下可根据实际业务需求,自行改写 $citys

Php Newbie, echo not working?

和自甴很熟 提交于 2020-01-08 06:37:05
问题 So this is almost definitely a newbie question, but I'm going through the w3 tutorial on php and on my server I can only get echo to work sometimes. For example in one trial they have me submitting inputs in one form and picking them up in another, and echo works in that case, but in this code it won't: <html> <body> <p> This should work!! <?php $str = "Hello, World!"; echo $str; ?> It failed... </p> </body> </html> The output should just be: This should work!! Hello, World! It failed... But

nginx 启动/停止/重启 BAT

試著忘記壹切 提交于 2020-01-08 03:09:15
cls @ECHO OFF SET NGINX_PATH=D: SET NGINX_DIR=D:\Hack\nginx\ color 0a TITLE Nginx 管理程序 Power By Ants GOTO MENU :MENU CLS ECHO. ECHO. * * * * Nginx 管理程序 Power By Ants * * * * * ECHO. * * ECHO. * 1 启动Nginx * ECHO. * * ECHO. * 2 关闭Nginx * ECHO. * * ECHO. * 3 重启Nginx * ECHO. * * ECHO. * 4 退 出 BAT * ECHO. * * ECHO. * * * * * * * * * * * * * * * * * * * * * * * * ECHO. ECHO.请输入选择项目的序号: set /p ID= IF "%id%"=="1" GOTO cmd1 IF "%id%"=="2" GOTO cmd2 IF "%id%"=="3" GOTO cmd3 IF "%id%"=="4" EXIT PAUSE :cmd1 ECHO. ECHO.启动Nginx...... IF NOT EXIST %NGINX_DIR%nginx.exe ECHO %NGINX_DIR%nginx.exe不存在 %NGINX_PATH

系统巡检

被刻印的时光 ゝ 提交于 2020-01-07 20:55:05
#!/bin/bash ** 系统信息 ** getsys(){ #系统类型 os_type= uname #系统版本 os_ver= cat /etc/redhat-release #系统内核 os_ker= uname -a|awk '{print $3}' #当前时间 os_time= date +%F_%T #运行时间 os_run_time= uptime |awk '{print $3,$4}'|awk -F ',' '{print $1}' #最后重启时间 os_last_reboot= who -b|awk '{print $3}' #本机名称 os_hostname= hostname echo “系统类型: ${os_type}” echo “系统版本: ${os_ver}” echo “系统内核: ${os_ker}” echo “当前时间: ${os_time}” echo “运行时间: ${os_run_time}” echo “最后重启时间: ${os_last_reboot}” echo “本机名称: ${os_hostname}” } main(){ getsys } main 网络信息 getnet(){ ipaddr=( ifconfig |grep -w inet|awk '{print $2}' ) echo “本机的ip地址:$

服务器上监控tomcat,如果挂掉则重启

本小妞迷上赌 提交于 2020-01-07 17:14:09
该脚本用于监控tomcat服务器是否可用,如果服务不可用则重启tomcat 略微修改后也可以用于其他服务的监控 monitor.sh 脚本如下 1 #!/bin/sh 2 3 4 # 定义要监控的页面地址 5 WebUrl="http://xxxxxxx.com" 6 GetPageInfo=/dev/null 7 8 9 while [ "1" = "1" ] 10 do 11 12 TomcatServiceCode=$(curl -s -o $GetPageInfo -m 10 --connect-timeout 10 $WebUrl -w %{http_code}) 13 echo "`date "+%Y-%m-%d %H:%M:%S"` : TomcatServiceCode:"$TomcatServiceCode 14 15 #如果返回不是http 200 ,说明tomcat已经挂断 16 #需要杀掉进程,并重启tomcat 17 if [ $TomcatServiceCode -eq 200 ];then 18 echo "`date "+%Y-%m-%d %H:%M:%S"` :tomcat is okay." 19 else 20 ID=`ps -ef | grep tomcat | grep -v "grep" | awk '{print $2}'` 21

shell脚本demo

 ̄綄美尐妖づ 提交于 2020-01-07 16:21:11
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 数组定义mytest=(hello world) echo ${mytest[1]}输出world echo ${mytest[*]} hello world mytest[1]=nihao变为hello nihao 删除 unset mytest[1] 删除全部 unste mytest #!bin/bash通知shell以bash/shell来执行程序 echo命令可以使用单引号和双引号来将文本字符串圈起来, 如果在文本字符串用到他们的话,要在文本中使用其中一个引号 > echo "hello 'world'" hello 'world' > echo 'hello "world"' hello "world" 同一行显示一个字符串作为命令输出[两边空格] echo -n " the time and date are " 输入重定向 wc <123.txt 206 614 41406 内联输入重定向是双小于号<<[必须指定一个文本标记来划分数据的开始和结尾] wc <<EOF > test string 1 > test string 2 > test string 3 > EOF 3 9 42 数学运算 expr 1 + 5[中间空格] 6 expr 1 * 5 expr: syntax error