Using PHP to invoke shell scripts to synchronize files

Source: Internet
Author: User
When you need to sync to another machine when uploading files, you can perform a shell script for file synchronization.

#! /bin/basha=$1b=$2ip=$3port=$4passwd=$5/bin/rpm -qa|/bin/grep -q expectif-ne0 ];thenecho"please install expect"exitfiif$#-ne5 ];thenecho"must 5 parameter,1:source file,2:object file,3:object ip 4:object port,5:passwd"exitfi"  spawn scp -P $port$a root@$ip:$b  expect {    \"*assword\" {set timeout 300; send \"$passwd\r\";}    \"yes/no\" {send \"yes\r\"; exp_continue;}  }  expect eof"

Run scripts need to install expect, directly yum installation can
Expect script is a kind of script language based on TCL, the exposure rate is not high, but it is a good base friend of shell script. Expect scripts are interactive and designed for interactive applications, often in conjunction with Telnet, FTP, fsck, rlogin, Tip, SCP, and more
If the script edited from win appears under Linux no such file or directory, can be executed under Linux VI script

:sef ff=unix

When PHP executes the shell script, remember to write the absolute path

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the use of PHP call Shell script synchronization files, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.