Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Linux batch copy data script     - tar command to extract a file error: stdin has more than one entry (Linux)

- CentOS 5.11 Open VNC access (Linux)

- in no backup ex: error: Xin Tourou ah backup child process has Singles DAT / US person / bin / in no backup ex (Database)

- Java, boolean operators & =, | = ^ = use (Programming)

- Nginx load balancing configuration (TCP proxy) (Server)

- VirtualBox installation enhancements let the mouse move and share CentOS 6.4 (Linux)

- MySQL binary packages install for RedHat Linux Enterprise 6.4 (Database)

- Ubuntu U disk do not have write privileges can only read but not write (Linux)

- Java rewrite equals method (Programming)

- Advanced Search Oracle study notes (Database)

- Installation in lxml Python module (Linux)

- Ubuntu 10.10 install Oracle 10g graphic tutorials (Database)

- Protobuf compiled and used on the Ubuntu 14.04 (Programming)

- Ubuntu 14.04 Nvidia graphics driver installation and settings (Linux)

- Linux system started to learn: Teaches you install Ubuntu 15.04 on VirtualBox (Linux)

- Use chattr and lsattr command to manage linux files and directory attributes (Linux)

- To create a full command line Android Build System (Linux)

- Different between Linux file path and the windows (Linux)

- How to use Git to upload code to GitHub project (Linux)

- The specified user to execute commands under Linux (Linux)

 
         
  Linux batch copy data script
     
  Add Date : 2018-11-21      
         
         
         
  Recently I tried to get hold of a copy of the Linux transmission Batch deploy remote server script.
Ideas:
1. establish equivalence with the remote client
2. Copy the data, or perform remote server commands
Automation equivalence script as follows: the premise is expect this package to install
================================================== ==============
The server generates automatically generate rsa key
#! / Usr / bin / expect
rm -rf root / .ssh / known_hosts
expect -c "
spawn ssh-keygen -t rsa
 expect {
 \ "* Id_rsa * \" {send \ r; exp_continue}
 \ "* Passphrase * \" {send \ r; exp_continue}
 \ "* Again * \" {send \ r; exp_continue}
}

================================================== =============
Copy the generated key to the remote server
 
for p in $ (cat /script/ip.txt)
do
ip = $ (echo "$ p" | cut -f1 -d ":")
password = $ (echo "$ p" | cut -f2 -d ":")
expect -c "
spawn ssh-copy-id -i /root/.ssh/id_rsa.pub root @ $ ip
        expect {
                \ "* Yes / no * \" {send \ "yes \ r \"; exp_continue}
                \ "* Password * \" {send \ "$ password \ r \"; exp_continue}
                \ "* Password * \" {send \ "$ password \ r \";}
        }
"
done
Wherein ip.txt content format is as follows:
192.168.1.56:123456
 
 
===============================================================
Execution services to client push command
 
for h in $ (cat /script/ip.txt|cut -f1 -d ":")
do
ssh root @ $ h "ls $ dire"
dire = "/ tmp / test"
if [$ -eq 0?];
then
ssh root @ $ h rm -rf "$ dire"
set timeout 300
ssh root @ $ h mkdir -p / tmp / test
fi
ssh root @ $ h touch lgl.txt
scp /root/CentOS-5.3-x86_64-bin-DVD.iso root@192.168.1.56: / home
set timeout 300
done
 
===============================================================
Finally, the script is as follows:
 
 
[Root @ lgl script] # cat ssh.sh
#! / Usr / bin / expect
rm -rf root / .ssh / known_hosts
expect -c "
spawn ssh-keygen -t rsa
 expect {
 \ "* Id_rsa * \" {send \ r; exp_continue}
 \ "* Passphrase * \" {send \ r; exp_continue}
 \ "* Again * \" {send \ r; exp_continue}
}
"
for p in $ (cat /script/ip.txt)
do
ip = $ (echo "$ p" | cut -f1 -d ":")
password = $ (echo "$ p" | cut -f2 -d ":")
expect -c "
spawn ssh-copy-id -i /root/.ssh/id_rsa.pub root @ $ ip
        expect {
                \ "* Yes / no * \" {send \ "yes \ r \"; exp_continue}
                \ "* Password * \" {send \ "$ password \ r \"; exp_continue}
                \ "* Password * \" {send \ "$ password \ r \";}
        }
"
done
for h in $ (cat /script/ip.txt|cut -f1 -d ":")
do
ssh root @ $ h "ls $ dire"
dire = "/ tmp / test"
if [$ -eq 0?];
then
ssh root @ $ h rm -rf "$ dire"
set timeout 300
ssh root @ $ h mkdir -p / tmp / test
fi
ssh root @ $ h touch lgl.txt
scp /root/CentOS-5.3-x86_64-bin-DVD.iso root@192.168.1.56: / home
set timeout 300
done
     
         
         
         
  More:      
 
- How to install CentOS 7.x in OpenERP (Odoo) (Linux)
- MySQL backup tool to back up mydumper (Database)
- MySQL 5.7 can not log in problem (Database)
- Linux System Getting Started Tutorial: permission to permanently modify the USB device in Linux (Linux)
- Linux file system (inode and block) (Linux)
- Linux System Getting Started Tutorial: how to find information on Linux-embedded module (Linux)
- CentOS installation pycurl (Linux)
- Getting Started with Linux system to learn: how to install the Shrew Soft IPsec VPN on Linux (Linux)
- Java executable file to read information from a database copy (Programming)
- How to install Zephyr Test Management Tools on CentOS 7.x (Server)
- ActiveMQ5.11.1 and JDK version matching relation (Linux)
- Oracle JDK installation under Ubuntu Linux (Linux)
- Android Notification (Programming)
- Java application server WildFly (Server)
- J2EE Example of Filter (Programming)
- Redhat Close SELinux correct step (Linux)
- Getting Started with Linux system to learn: How to compress JPEG images on the command line (Linux)
- Ubuntu 14.04 + xRDP + Xfce implement Windows Remote Desktop Connection (Linux)
- TPCC-MySQL Benchmark (Database)
- How to release the cache memory on Linux (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.