同步git修改文件到远端服务器脚本
1 #!/usr/bin/perl -w 2 @files=`git status -s` ; 3 @sync_files = (); 4 5 foreach (@files) 6 { 7 $file = substr($_,3); # 固定前2个字符为状态 + 1个空格 8 chomp($file); 9 push(@sync_files, $file); 10 } 11 12 $cmd = "scp -r "; 13 foreach $file (@sync_files) 14 { 15 $cmd = $cmd.$file." "; 16 } 17 18 $cmd = $cmd.' ops@192.168.1.1:/home/ops/'; 19 20 print $cmd."\n"; 21 system($cmd);