shell 免交互 Here Documents

# 例子:cat 免交互
cat >filename.sh<<EOF
123
ABCabc
EOF

# 例子:vim 免交互
#!/bin/bash
vim tao.txt<<EOF
i       #进入插入模式
nihao   #输入nihao 
^[      #这个符号是在Ctrl+v下按ESC键,意为按下ESC退出编辑模式
:wq     #保存退出
EOF

# 例子:密码免交互
#!/bin/bash
创建用户密码时
useradd tao
passwd tao <<EOF
litao_59
litao_59
EOF

# 例子:ftp免交互
#!/bin/bash
ftp -v -n 192.168.1.171 << END
user guest 123456
binary
hash
cd /home/data
lcd /home/databackup
prompt
mput *
bye
END

 

posted on 2023-10-24 10:36  luokeli  阅读(14)  评论(0)    收藏  举报

导航