[root@jbossshell]#catgetopts.sh#!/bin/bash#date=2014-09-16#istopracticethegetoptswhilegetopts"a:bc"arg(:前面的变量是一定要跟参数的)do case$argin a) echo"a‘sarg:$OPTARG" ;; b) echo"b" ;; c) echo"c" ;; ?) echo"unkownargument" exit1 ;; esacdone[root@j..
分类:
其他好文 时间:
2014-09-16 19:09:31
阅读次数:
205
sed中引入shell变量的四种方法1.evalsed’s/$a/$b/’filename2.sed"s/$a/$b/"filename3.sed’s/’$a’/’$b’/’filename4.seds/$a/$b/filename
分类:
其他好文 时间:
2014-09-16 19:08:51
阅读次数:
165
[root@jbossshell]#catshift.sh#!/bin/bashuntil[$#-eq0];doecho"thefirstis:$1totalis$#"shiftdone[root@jbossshell]#./shift.sh123456thefirstis:1totalis6thefirstis:2totalis5thefirstis:3totalis4thefirstis:4totalis3thefirstis:5totalis2thefirstis:6totalis1[root@jbos..
分类:
其他好文 时间:
2014-09-16 19:07:41
阅读次数:
147
该Shell脚本用于实现将DB2数据库表导出到文件,将在另一篇博文《Java代码调用Shell脚本并传入参数实现DB2数据库表导出到文件》中通过Java代码实现调用该脚本并传入参数。#!/usr/bin/envsh
DBSCHEMA=$1
DBUSER=$2
DBPASSWORD=$3
TABLENAME=$4
FILEPATH=$5
DELIMITER=$6
EXPORTL..
分类:
数据库 时间:
2014-09-16 19:07:21
阅读次数:
273
本文通过Java代码调用Shell脚本并传入参数实现DB2数据库表导出到文件,代码如下:importjava.io.File;
importjava.io.IOException;
importjava.io.InputStreamReader;
importjava.io.LineNumberReader;
importjava.util.HashMap;
importorg.slf4j.Logger;
importorg.slf4j.Log..
分类:
数据库 时间:
2014-09-16 19:06:21
阅读次数:
320
最近同事写的shell脚本在ubuntu上跑时总走不对if的分支。发现ubuntu上的shell默认是bash,但sh对应的是dash,这个需要注意。
1
ubuntu上sh连到dash:
zxw@hostname1:~$ uname -a
Linux hostname1 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17...
分类:
其他好文 时间:
2014-09-16 17:24:31
阅读次数:
293
1.很系统供应商不允许使用这一命令,或者即使被置位,也会被忽略,这一命令会带来安全性风险。suid意味着该用户对自己的shell脚本设置了这种权限,那么其他用户执行该脚本时,也将拥有该用户相同的权限。如果根用户设置了这样的权限,那么其他普通用户在执行这一脚本时,将有根用户的权限。同样的原则也适用于g...
分类:
其他好文 时间:
2014-09-16 17:17:20
阅读次数:
174
[root@vapp0301~]#catpull_log.sh#!/bin/bash#date=2014-09-16#istopulltheapplogecho-ne"\033[31m\033[05mthetimeformatoftheriskandbpis%Y-%m-%d%H:%M:%S.theposis%H:%M:%S\033[0m"read-p"pleaseinputyourapp":APPread-p"pleaseinputyourtimeinterval":TIME1read-p"pleaseinp..
分类:
其他好文 时间:
2014-09-16 16:06:40
阅读次数:
189
[root@gxapp01shells]#catcheck_saqz.sh#!/bin/bash#date=2014-09-06#istocheckthehttpstatus.ifitisnotOK,restarttheprogressrestart_saqz(){kill-9`ps-elf|grepjboss-saqz|grep-v"grepjboss-saqz"|awk-F‘‘‘{print$4}‘|tail-1`rm-rf/usr/local/jboss/server/jboss-saqz/tmp/*r..
分类:
其他好文 时间:
2014-09-16 16:05:51
阅读次数:
164
[root@jbossshell]#catzabbix.sh#!/bin/bashset-xHOST=`hostname`DIR=/rootserviceiptablesstopAZ(){groupaddzabbixuseraddzabbix-gzabbix-s/sbin/nologintar-zxvf$DIR/zabbix-1.8.5.tar.gzcdzabbix-1.8.5./configure--prefix=/usr/local/zabbix--enable-agentmakemakeinstallm..
分类:
其他好文 时间:
2014-09-16 16:05:31
阅读次数:
176