hive.sh
#!/bin/sh
TIME = `date -d "1 day ago" +%Y%m%d`
hive -e "select * from tablename where date = $TIME" >> /home/"$TIME".txt
/usr/bin/expect/<<-EOF
spawn scp /home/$TIME.txt root@x.x.x.x:/home/
set timeout -1(设置时间为无穷大,默认30s,文件如果太大,还没传输完,连接就会中断)
expect "*password*"
send "******\r"
expect eof
EOF