标签:shell
作者:iamlaosong
我们经常在shell脚本程序中用<<EOF重定向输入,将我们输入的命令字符串作为一个执行程序的输入,这样,我们就不需要在那个程序环境中手工输入命令,以便自动执行我们需要的功能,例如:
sqlplus emssxjk/emssxjk <<EOF select count(*) from sncn_yxyj where create_date like sysdate; EOF
sqlplus emssxjk/emssxjk <<STD select count(*) from sncn_yxyj where create_date like sysdate; STD
需要注意的是,第一个EOF必须以重定向字符<<开始,第二个EOF必须顶格写,否则会报错。
再看一个自动FTP的例子:
#ftp data to 10.178.37.244
rq=`date +%Y%m%d`
cd /data/product/song
ftp -i -n <<!
open 10.178.37.244
user oracle post
cd ems
bin
put ${rq}.dat
bye
!
标签:shell
原文地址:http://blog.csdn.net/iamlaosong/article/details/40509399