echo

批量执行特定文件目录下SQL文件脚本

折月煮酒 提交于 2020-01-28 03:35:01
项目需要执行许多SQL脚本文件,网上搜搜没发现特别合适的,花了点时间自已写了一个,主要分为两个批处理文件 main.bat 用关于查找所有需要执行的SQL文件     @echo on     for /r "C:\Documents and Settings\j1jiang\My Documents\sql scripts" %%i in (*.sql,*.prc) do call sub "%%i"     @echo off 替换 "C:\Documents and Settings\j1jiang\My Documents\sql scripts" 为需要的目录 sub.bat 调用sqlcmd.exe 执行SQL文件 echo Start execute %~1 >>result.txt     sqlcmd -U <user> -P <password> -S server\instanceName -d <dbname> -i %1 >>result.txt     echo execute sql %~1 completed! >>result.txt     echo -------------------------------------------------------------------------->>result.txt 来源: https:/

Escaping a batch file echo that starts with a forward slash and question mark

淺唱寂寞╮ 提交于 2020-01-28 00:07:34
问题 Bit of a tricky one. How can I correctly escape the following in a batch file? echo /? display this help text This particular combination of characters is treated as an "ECHO /?" command: C:\Batch>ECHO /? display this help text Displays messages, or turns command-echoing on or off. ECHO [ON | OFF] ECHO [message] Type ECHO without parameters to display the current echo setting. It does not respond to caret (^) escaping, ie. I've tried ^/? /^? and ^/^?. NB: As a workaround, I found that

批量改名总结

我与影子孤独终老i 提交于 2020-01-27 20:34:42
http://bbs.chinaunix.net/thread-554405-1-1.html 承蒙CU各位大侠关照,现将自己搜集整理的文件批量改名方法总结如下,有原创也有引用,引用恕不一一注明。学习研究中经常碰到批量文件改名问题,所以下决心一劳永逸地解决了这个问题,不正之处请方家指正,欢迎评点、补充,谢谢! A 加后缀 1.问题:同以目录下有海量以日期命名的文件,其中有的有后缀,有的以点结尾,如20020101.,20020102.,……,20020101.td,20020102.td…… 要求: 把所有以点结尾的加上后缀.ts 我的方法: #!/bin/bash for files in `ls *.` do mv $files `echo "$filests" ` done 2. 同上 mv $files ${files}ts 3. 同上 mv $files `$files.ts|sed 's/\.//' ` 4. file =>file.txt mv $files $files.txt 5. *.04 => *04.txt mv $files $(echo ${files}.txt|sed 's/\.//1') 或者 mv $files `echo ${files}.txt|sed 's/\.//1' ` B 改后缀(.old => .new) 1. rename

bat批处理延迟运行脚本(zz)

ⅰ亾dé卋堺 提交于 2020-01-27 19:02:10
@echo off :aaa pause 这里是你需要运行的程序 for /l %%i in (0,1,10000) do echo %%i>nul goto aaa 当然bat延迟运行还有其他的一些方法 不过我这个算很简单了 你还可以使用两个for代替goto for /l %%i in (0,1,10000) do echo %%i>nul 这里>nul忽略输出 如果程序是无法自动回到cmd界面的那可能需要结束她的进程什么的 自然利用bat调用其他程序也能做到例如ntsd debug 等等 或者是vbs 不过那就显不出bat的特性出来了 ping延时还是很精确的,呵呵。 @echo off :aaa echo %TIME% ping 0.0.0.1 -n 1 -w 500>nul goto aaa I:\>delay 18:51:41.50 18:51:42.42 18:51:43.42 18:51:44.42 18:51:45.42 18:51:46.42 18:51:47.42 18:51:48.42 18:51:49.42 18:51:50.42 18:51:51.42 18:51:52.42 18:51:53.42 18:51:54.42 18:51:55.42 18:51:56.42 ^C终止批处理操作吗(Y/N)? y Windows的ping

nginx 启动重启脚本

删除回忆录丶 提交于 2020-01-27 14:48:42
#! /bin/sh # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts the nginx web server PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC= "nginx daemon" NAME=nginx <span style= "color: #ff0000;" ><strong>DAEMON=/usr/local/nginx/sbin/$NAME CONFIGFILE=/usr/local/nginx/conf/$NAME.conf PIDFILE=/usr/local/nginx/logs/$NAME.pid</strong></span> SCRIPTNAME=/etc/init.d/$NAME set -e [ -x "$DAEMON" ] || exit 0 do_start() { $DAEMON -c $CONFIGFILE || echo -n "nginx already running" } do_stop() { kill -INT `cat $PIDFILE` || echo -n "nginx not running" } do_reload() {

centOS下安装nginx

蹲街弑〆低调 提交于 2020-01-27 02:16:50
1、安装pcre-8.41   tar -xvf pcre-8.4.1.tar.gz   cd pcre-8.4.1   ./configure   make && make install 2、安装zlib-1.2.11 3、安装nginx   tar -xvf nginx-1.12.2.tar.gz   cd nginx-1.12.2   ./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-pcre=../pcre-8.41 --with-zlib=../zlib-1.2.11   make && make install 4、nginx开机自启动 4.1 vim /etc/init.d/nginx (红色两行一定要添加) #! /bin/sh # chkconfig: - 85 15 # description: nginx is a World Wide Web server. It is used to serve PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC=

PHP Function

梦想的初衷 提交于 2020-01-27 00:11:01
<?php //1.require(fatal error) and include(warning error) echo 'This is the main file.<br />'; require('reusable.php'); echo 'The script will end now.<br />'; /* there are three situations here 1. if the reusable.php are those codes, which includes php tags <?php echo 'Here is a very simple PHP statement.<br />'; ?> then, codes will be processed by php engine, finally <?php echo 'This is the main file.<br />'; echo 'Here is a very simple PHP statement.<br />'; echo 'The script will end now.<br />'; 2.if not include php tags, the reusable.php source codes will be treated as plain HTML text

shell小脚本集合

拥有回忆 提交于 2020-01-26 19:58:33
1.猜数字 #!/bin/bash x=$[RANDOM%10+1] while read -p "please your number1-10:" num;do #echo $num if [ "$num" -eq "$x" ];then echo your gueess right. break elif [ "$num" -lt "$x" ];then echo letter else echo more fi done 2.棋盘 #!/binbash red="\033[41m" blue="\033[44m" cloend="\033[0m" #echo -e "$red $cloend" for j in {1..8};do if [ $[j%2] -eq 1 ];then for i in {1..8};do if [ $[i%2] -eq 1 ];then echo -e "$red $cloend\c" else echo -e "$blue $cloend\c" fi done elif [ $[j%2] -eq 0 ];then for k in {1..8};do if [ $[k%2] -eq 0 ];then echo -e "$red $cloend\c" else echo -e "$blue $cloend\c" fi done fi echo

Linux Shell 函数返回值

那年仲夏 提交于 2020-01-26 17:46:14
Shell函数返回值,常用的两种方式: return , echo 1) return 语句 shell函数的返回值,可以和其他语言的返回值一样,通过return语句返回。 示例: #!/bin/sh function test() { echo "arg1 = $1" if [ $1 = "1" ] ;then return 1 else return 0 fi } echo echo "test 1" test 1 echo $? # print return result echo echo "test 0" test 0 echo $? # print return result echo echo "test 2" test 2 echo $? # print return result 输出结果为: test 1 arg1 = 1 1 test 0 arg1 = 0 0 test 2 arg1 = 2 0 先定义了一个函数test,根据它输入的参数是否为1来return 1或者return 0。 获取函数的返回值通过调用函数,或者最后执行的值获得。 另外,可以直接用函数的返回值用作if的判断。 注意:return只能用来返回整数值,且和c的区别是返回为正确,其他的值为错误。 3) echo 返回值 其实在shell中,函数的返回值有一个非常安全的返回方式

日常小脚本

Deadly 提交于 2020-01-26 14:35:44
通过位置变量创建 Linux 系统账户及密码 #!/bin/bash for i in {1…5} do cat /etc/passwd|grep user$i if [ $? -eq 0 ];then echo “用户已存在” else a= openssl rand -base64 8 passwd= echo ${a:5:0} useradd user$i echo "$passwd" |passwd --stdin user$i echo -e "\033[31m 用户: user$i 密码: $passwd \033[0m">>passwd.txt fi done 每周 5 使用 tar 命令备份/var/log 下的所有日志文件 tar -czf log- date +%Y%m%d .tar.gz /var/log ]# crontab -e -u root 00 03 * * 5 /root/logbak.sh 监控本机内存和硬盘剩余空间,剩余内存小于 500M、根分区剩余空间小于 1000M 时,发送报警邮件给 root 管理员 #!/bin/bash #提取根分区剩余空间 disk_size=$(df | awk 'NR==2{print $4}') #提取内存剩余空间 mem_size=$(free | awk 'NR==2{print $4}') while