{"id":360,"date":"2007-09-21T23:59:07","date_gmt":"2007-09-21T15:59:07","guid":{"rendered":"http:\/\/blog.smallken.ink\/2007\/09\/21\/linux\/360.html"},"modified":"2007-09-21T23:59:07","modified_gmt":"2007-09-21T15:59:07","slug":"windows-xp-%e6%89%b9%e6%ac%a1%e6%aa%94%e8%88%87-linux-%e7%9a%84-shell-script-%e6%93%8d%e4%bd%9c%e5%82%99%e5%bf%98","status":"publish","type":"post","link":"https:\/\/blog.smallken.site\/?p=360","title":{"rendered":"Windows XP \u6279\u6b21\u6a94\u8207 Linux \u7684 shell script \u64cd\u4f5c\u5099\u5fd8"},"content":{"rendered":"<p>\u9019\u662f\u70ba\u4e86\u8981\u89e3\u6c7a\u6211\u96fb\u8166\u7684\u4e00\u500b\u554f\u984c\uff0c\u5c31\u662f\u6211\u7684 Linux \u7ad9\u662f\u7528VMware\u67b6\u8d77\u4f86\u7684\uff0cLinux \u7684IP\u662f\u7528\u64a5\u63a5\u7684\u56fa\u5b9aIP\uff0c\u800cWindows XP\u662f\u64a5\u63a5\u7684\u52d5\u614bIP\uff0c\u554f\u984c\u662f\u52d5\u614bIP\u4e0d\u80fd\u4f54\u6709\u592a\u4e45\uff0c\u4e00\u6bb5\u6642\u9593\u5c31\u6703\u5f37\u8feb\u63db\u4e00\u500bIP\uff0c\u6240\u4ee5\u6211\u5728\u9060\u7aef\u684c\u9762\u6642\u5c31\u5f88\u96e3\u638c\u63e1Windows XP\u7684IP\u5230\u5e95\u662f\u591a\u5c11? \u70ba\u4e86\u89e3\u6c7a\u9019\u500b\u554f\u984c\u6211\u505a\u4e86\u4ee5\u4e0b\u5de5\u4f5c\u3002<\/p>\n<p>\u6982\u5ff5:<br \/>1.\u4ee5\u4e0b\u6240\u6709\u52d5\u4f5c\u5fc5\u9808\u6bcf\u5929\u81ea\u52d5\u57f7\u884c<br \/>2.\u5728XP\u4e2d\u5148c:\\&gt;ipconfig &gt; ip.txt\uff0c\u5148\u5f97\u5230\u76ee\u524dIP\u4e14\u5b58\u6210ip.txt\u6587\u5b57\u6a94<br \/>3.\u628aip.txt\u7528ftp\u4e0a\u50b3\u5230Linux\u4e2d\u7684\u67d0\u4e00\u500b\u7a7a\u9593<br \/>4.\u5728linux\u4e2d\u5f97\u5230ip.txt\uff0c\u628aIP\u6488\u51fa\u4f86\u66f4\u65b0DNS<\/p>\n<p>\u5be6\u4f5c:<\/p>\n<p><!--more--><\/p>\n<p>1.Windwos XP\u4e2d\u5beb\u4e00\u500b\u6279\u6b21\u6a94 <br \/>&#8212; run.bat <a href=\"mailto:---@echo\">&#8212;<br \/>@echo<\/a> off<br \/>ipconfig &gt; ip.txt<br \/>ftp -v -n -i -s:ftp.txt <\/p>\n<p>2.ftp.txt \u5beb\u767b\u5165ftp\u6642\u4e0b\u7684\u6307\u4ee4\uff0c\u9810\u5beb\u597d\u8207 run.bat \u653e\u5728\u4e00\u8d77<br \/>&#8212; <a href=\"ftp:\/\/ftp.txt\">ftp.txt<\/a> &#8212;<br \/>open 192.168.1.100<br \/>user<br \/>smallken<br \/>&lt;passwd&gt;<br \/>put ip.txt<br \/>bye <\/p>\n<p>3.\u5728 Linux \u4e2d\u5beb\u4e00\u652fscript\u6a94<br \/>&#8212; update_dns.sh &#8212;<\/p>\n<p>#!\/bin\/bash <br \/># \u66f4\u65b0 testip.vblog.tw \u7684 IP<\/p>\n<p># dnsip: \u539f\u672cdns server \u7684 IP \u8a2d\u5b9a<br \/>dnsip=$(grep &#8216;testip&#8217; \/var\/named\/chroot\/var\/named\/vblog.tw.zone | awk &#8216;{print $3}&#8217;)<br \/># xpip: XP \u7684 IP<br \/>xpip=$(tail -n 3 \/home\/smallken\/ip.txt | grep IP | awk &#8216;{print $15}&#8217;) <br \/># dnsdate: dns \u7684 serial number\uff0c\u4ee5\u65e5\u671f\u4f86\u7de8\u865f<br \/>dnsdate=$(grep &#8220;seria&#8221; \/var\/named\/chroot\/var\/named\/vblog.tw.zone | awk &#8216;{print $1}&#8217;)<br \/># today: \u4ee5\u4eca\u5929\u7684\u65e5\u671f\u4f86\u7576 dns \u7684 serial number<br \/>today=$(date &#8220;+%Y%m%d1&#8221;) <br \/># \u5982\u679cxp\u7684IP\u8207\u539f\u4f86dns\u8a2d\u5b9a\u7684IP\u4e0d\u540c\uff0c\u5247\u66f4\u65b0 dns \u7684 zone \u8cc7\u8a0a<br \/>if [ &#8220;$dnsip&#8221; != &#8220;$xpip&#8221; ]; then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sed -e &#8220;s\/$dnsip\/$xpip\/gi&#8221; -e &#8220;s\/$dnsdate\/$today\/gi&#8221; \/var\/named\/chroot\/var\/named\/vblog.tw.zone &gt; \/tmp\/tmp.zone.txt<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mv \/tmp\/tmp.zone.txt \/var\/named\/chroot\/var\/named\/vblog.tw.zone<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; service named reload<br \/># \u628a IP mail \u7d66\u81ea\u5df2<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cat \/home\/smallken\/ip.txt | mail -s `date` <a href=\"mailto:smallken@gmail.com\">smallken@gmail.com<\/a><br \/>fi<\/p>\n<p>4.\u300c\u958b\u59cb\u300d\u2192\u300c\u8a2d\u5b9a\u300d\u2192\u300c\u63a7\u5236\u53f0\u300d\u2192\u300c\u6392\u5b9a\u7684\u5de5\u4f5c\u300d\u8a2d\u5b9a XP \u4e2d\u7684 run.bat \u6bcf\u5929\u65e9\u4e0a7\u9ede\u8dd1 <\/p>\n<p>5. Linux \u4e2d\u7684 update_dns.sh \u6bcf\u5929\u65e9\u4e0a8\u9ede\u8dd1<br \/># vi \/etc\/crontab<br \/>1 8 * * * root \/root\/update_dns.sh <\/p>\n<p>\u90fd\u8a2d\u5b9a\u597d\u4e4b\u5f8c\uff0c\u6211\u6bcf\u6b21\u9060\u7aef\u9023\u7dda\u53ea\u8981\u9023testip.vblog.tw\u5c31\u597d\u56c9^^<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9019\u662f\u70ba\u4e86\u8981\u89e3\u6c7a\u6211\u96fb\u8166\u7684\u4e00\u500b\u554f\u984c\uff0c\u5c31\u662f\u6211\u7684 Linux \u7ad9\u662f\u7528VMware\u67b6\u8d77\u4f86\u7684\uff0cLinux \u7684IP\u662f\u7528\u64a5\u63a5\u7684&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-360","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/blog.smallken.site\/index.php?rest_route=\/wp\/v2\/posts\/360","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.smallken.site\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.smallken.site\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.smallken.site\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.smallken.site\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=360"}],"version-history":[{"count":0,"href":"https:\/\/blog.smallken.site\/index.php?rest_route=\/wp\/v2\/posts\/360\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.smallken.site\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.smallken.site\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.smallken.site\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}