Crontab Execution Scp.exp failed

Source: Internet
Author: User

Recently a detection script was made and sent logs to the relevant server. The script test is normal, and the log is sent normally, so join crontab

However, it is not possible to execute in crontab. Check the crontab running status, script execution permissions, environment variables, and so on, all normal, the script still cannot execute.

Later found a post, said Scp.exp have a problem

The following are: Scp.exp

#!/usr/bin/expect-f


Set CMD0 [lindex $argv 0]

Set CMD1 [lindex $argv 1]

Set PASS "[Email protected]"


Spawn scp-r $CMD 0 $CMD 1


Set Timeout 10

Expect {

"* (yes/no) *" {send "yes\r"}

"*password*" {send "${pass}\r"}

}


Interact


Finally Scp.exp stays on the interaction, and the password cannot be entered, and has failed. Interaction must be terminated

Modified SCP.EXP Success

Modify the following

#!/usr/bin/expect-f


Set CMD0 [lindex $argv 0]

Set CMD1 [lindex $argv 1]

Set PASS "[Email protected]"


Spawn scp-r $CMD 0 $CMD 1


Expect {

"* (yes/no) *" {send "yes\r"}

"*password*" {send "${pass}\r"}

}


#interact

Set Timeout 20

Expect EOF

Exit


This article is from the "OPS rookie" blog, please be sure to keep this source http://ckl893.blog.51cto.com/8827818/1682295

Crontab Execution Scp.exp failed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.