[BashShell program design] when whileread encounters ssh
Source: Internet
Author: User
[BashShell program design] when whileread encounters ssh, first read a simplified BASHSHELL code TODAY 'date + % Y % m % d' SUFFIX & quot; tar & quot; CONFthe_config_filei0whilereadHOSTSRCPATHDSTPATHdo (I ++ )) [Bash Shell program design] when while read encounters ssh, first look at a simplified bash shell code TODAY = 'date + % Y % m % d' SUFFIX = "tar" CONF = the_config_file I = 0 while read host srcpath dstpath do (I ++ )) if ["X $ {HOST: 0: 1} "=" X # "-o $ {# DSTPATH}-eq 0] then # ignore annotation lines and records with less than three items else ssh $ {HOST}" tar c $ {SRCPATH} ">$ {DSTPATH }. $ {TODAY }. $ {SUFFIX} 2>/dev/null fi done <$ CONF the author intended to read the configuration file $ CONF through a script, and then package and back up the file specified in $ CONF, after the program is executed, it is found that the program will exit after successfully backing up the first file specified in $ CONF ...... After tracking, it is found that no data is read after the first file is backed up, so the while loop ends -- that is, ssh $ {HOST} "tar c $ {SRCPATH}" >$ {DSTPATH }. $ {TODAY }. $ {SUFFIX} 2>/dev/null. Change it to ssh $ {HOST} "tar c $ {SRCPATH}" >$ {DSTPATH}. $ {TODAY}. $ {SUFFIX} 2>/dev/null
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.