Here is simple script to copy using scp and expect ,
We are creating a simple script on the fly and run that script
cat > /tmp/copy_from_remote.sh << EOF
#!/usr/bin/expect
set timeout 10
log_user 0
spawn scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $REMOTE_CREDENTIAL_USERNAME@$host_name :$
expect "*?assword"
send "$CREDENTIAL_PASSWORD\r"
expect "*100\%*\r"
EOF
chmod 777 /tmp/copy_from_remote.sh
sh /tmp/copy_from_remote.sh
Once script is ready need to run .
For details we can add exp_internal 1 in the expect script
Need to disable host key checking and known host file .
We are creating a simple script on the fly and run that script
cat > /tmp/copy_from_remote.sh << EOF
#!/usr/bin/expect
set timeout 10
log_user 0
spawn scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $REMOTE_CREDENTIAL_USERNAME@$host_name :$
expect "*?assword"
send "$CREDENTIAL_PASSWORD\r"
expect "*100\%*\r"
EOF
chmod 777 /tmp/copy_from_remote.sh
sh /tmp/copy_from_remote.sh
Once script is ready need to run .
For details we can add exp_internal 1 in the expect script
Need to disable host key checking and known host file .
hey nice post meh, You are one of the best writers I've seen of recent. I love your style of blogging here. this post reminds me of an equally interesting post that I read some time ago on Daniel Uyi's blog: What's Extraordinary About Gurus? .
ReplyDeletekeep up the good work friend. I will be back to read more of your posts.
Regards
Thanks Daniel ..
ReplyDelete