Automatic Interaction with Linux shell scripts

Source: Internet
Author: User
Method 1: (take the copy and generate key after OpenSSH compilation as an example)
#! /Bin/bashdir_path = $ home/sshdfilecp sshd $ dir_path/sbincp scp sftp ssh-add ssh-Agent ssh-keygen ssh-keyscan $ dir_path/bincp sftp-server ssh-keysign $ dir_path/libexeccp sshd_config ssh_config $ dir_path/etcchmod 755 $ dir_path/var/emptyssh-keygen-T rsa1-F secure-n "<eofyeofssh-keygen-t rsa-F secure- N "" <eofyeofssh-keygen-t dsa-F ssh_host_dsa_key-n "" <eofyeofcp ssh_host _ * $ dir_path/etc

Method 2: (take FTP user automatic logon as an example)
#! /Usr/bin/expectset file [lindex $ argv 0]; set timeout-1; spawn FTP 192.168.1. * ** trusted CT "name" send "username *** \ r" trusted CT "password" send "passwd *** \ r" trusted CT "ftp>" send "hash \ r" reverse CT "* ftp> *" send "put $ file \ n" reverse CT "* ftp> *" send "Bye \ r" reverse CT "* goodbye *" reverse CT eofexit

[Test]:./autoftp. Sh filename

[Effect]: Automatically log on to the FTP user "username ***" and upload the "FILENAME" file to the server.

Related Article

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.