C语言 c++ php mysql nginx linux lnmp lamp lanmp memcache redis 面试 笔记 ppt 设计模式 问题 远程连接

随笔 - 305  文章 - 1  评论 - 50  阅读 - 168万

脚本 用 scp 拷贝文件

 

复制代码
#!/usr/bin/expect

set proj_dir /home/jksong/NewsSpark/openid_for_commonid
set tmp_data_dir $proj_dir/data_src/openid_dir
set password yourpassword

spawn scp -r $tmp_data_dir news@10.49.94.67:/data/news/data/commid_stroage_server/original
set timeout 300
for {} {1} {} { 
    expect {
        "*re you sure you want to continue connecting (yes/no)?" {
            send "yes\r" 
        }        
        "*assword:" {
            send "$password\r"
        }        
        "*ermission denied*" {
            break       
        }       
        "*No route to host" {
            break
        }
        "*No such file or directory" {
            break
        }
        timeout {
            break
        }
        eof {
            break
        }
    }
}
interact

exit
复制代码

 

复制代码
#!/bin/sh

rsynData()
{
   if [ $# -eq "3" ];then
    src=$1
    dest=$2
    pwd=$3

    expect -c "
        spawn scp -r $src $dest
        expect {
                \"*assword\" {set timeout 300; send \"${pwd}\r\";}
                \"yes/no\" {send \"yes\r\"; exp_continue;}
               }
    expect eof"
   fi
}


rm -rf /data/kb_user_pindao/$1
rsynData jksong@192.168.0.1:/home/jksongNewsHadoop/kb_user_pindao/$1  /data/kb_user_pindao/ password

for p in `ls  "/data/kb_user_pindao/$1"`
do
    /usr/local/php/bin/php /data/inews_server_cms/server/cache_tools/channel_recomm/importInterestChannelToRedis.php /data/kb_user_pindao/$1/$p
done
复制代码

 

posted on   思齐_  阅读(3951)  评论(0编辑  收藏  举报
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示