2016-04-27 7 views
0

私はすでに前に同様の質問を掲載して助けを得ましたが、それを変更しましたがまだ動作しません。私は離れた場所にscpして、1日後に最新のファイルを取得しようとしています。それは私自身がコマンドを実行するときに機能します。これは、権限に文句を言うが、それはアクセス許可の問題ではありませんexpectスクリプトでfind-anct -ctimeと一緒に使用されたSCPが動作しません

#!/usr/bin/expect -f 
exp_internal 1 
set host_ip [lindex $argv 0 ] 
set user [lindex $argv 1 ] 
set password [lindex $argv 2] 
set scp_remote_directory [lindex $argv 3 ] 
set local_directory [lindex $argv 4] 

set force_conservative 1 ;# set to 1 to force conservative mode even if 
          ;# script was not run conservatively originally 
if {$force_conservative} { 
     set send_slow {1 .1} 
     proc send {ignore arg} { 
       sleep .1 
       exp_send -s -- $arg 
     } 
} 

set timeout -1 
#spawn scp [email protected]$host_ip:$scp_remote_directory/$scp_remote_filename $local_directory/ 
#spawn rsync -azv [email protected]$host_ip:\´\$(find\ $scp_remote_directory\ -ctime\ -1\)\´ $local_directory/ 
#spawn scp [email protected]$host_ip:\'\$(find\ $scp_remote_directory\ -ctime\ -1)\' $local_directory/ 
spawn scp [email protected]$host_ip:\`\$(find\ $scp_remote_directory\ -ctime\ -1\)\` $local_directory/ 
#spawn scp [email protected]$host_ip:$scp_remote_directory/CscfHealthCheckReport_$TagID_$phase* $local_directory/ 
match_max 100000 
expect { 
    -exact "Are you sure you want to continue connecting (yes/no)? " { 
    send -- "yes\r" 
    exp_continue 
    } 
    -exact "${user}@${host_ip}'s password: " { 
    send -- "$password\r" 
    } 
    -exact "Password: " { 
    send -- "$password\r" 
    } 
} 
expect eof 

これは次のようにスクリプトがどのように見えるかです。もし私がSCP行を `to 'に変更すると、別の問題が発生します。ここ

がプリントアウトである:

/td_general_scp.exp 10.33.122.22 root rootroot /cluster/storage/no-backup/coremw/var/log/saflog/FaultManagementLog/alarm/Fm*.log /home/imstest/shared/Generate/ReportingT3/tmp 
spawn scp [email protected]:`$(find /cluster/storage/no-backup/coremw/var/log/saflog/FaultManagementLog/alarm/Fm*.log -ctime -1)` /home/imstest/shared/Generate/ReportingT3/tmp/ 
parent: waiting for sync byte 
parent: telling child to go ahead 
parent: now unsynchronized from child 
spawn: returns {141218} 

expect: does "" (spawn_id exp6) match exact string "Are you sure you want to continue connecting (yes/no)? "? no 
"[email protected]'s password: "? no 
"Password: "? no 
Password: 
expect: does "Password: " (spawn_id exp6) match exact string "Are you sure you want to continue connecting (yes/no)? "? no 
"[email protected]'s password: "? no 
"Password: "? yes 
expect: set expect_out(0,string) "Password: " 
expect: set expect_out(spawn_id) "exp6" 
expect: set expect_out(buffer) "Password: " 
send: sending "rootroot\r" to { exp6 } 

bash: /cluster/storage/no-backup/coremw/var/log/saflog/FaultManagementLog/alarm/FmAlarmLog_20160422_152507_20160426_135452.log: Permission denied 
expect: read eof 
expect: set expect_out(spawn_id) "exp6" 
expect: set expect_out(buffer) "\r\nbash: /cluster/storage/no-backup/coremw/var/log/saflog/FaultManagementLog/alarm/FmAlarmLog_20160422_152507_20160426_135452.log: Permission denied\r\n" 

スクリプトの名前は、助けを

td_general_scp.expおかげです。

答えて

0

リモートシェルは​​を実行し、ファイル名を発行します。それは見つけることです。

しかし、これをバッククォートで囲むので、今度はの検索結果をスクリプトとして実行しようとしています。

おそらく、scpから離れてrsyncを使用したいと思うかもしれません。

+0

こんにちはグレン、入力していただきありがとうございますが、私もrsyncを試しました。このリンクでも同様の質問がありました。同じ種類のエラーをチェックアウトします。 [リンク](http://stackoverflow.com/questions/36785164/using-rsync-in-expect-script-with-find-ctime-give-me-an-error)私はその提案を得たので、ダニで囲んだその質問に。 – MaestroGarcia

関連する問題