{"id":110,"date":"2012-05-11T17:37:22","date_gmt":"2012-05-11T09:37:22","guid":{"rendered":"http:\/\/www.freezhongzi.info\/?p=110"},"modified":"2012-05-11T17:37:22","modified_gmt":"2012-05-11T09:37:22","slug":"ftp%e4%b8%8b%e8%bd%bdshell%e8%84%9a%e6%9c%ac%e7%bc%96%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/bl4kraven.com\/index.php\/2012\/05\/11\/ftp%e4%b8%8b%e8%bd%bdshell%e8%84%9a%e6%9c%ac%e7%bc%96%e7%a8%8b\/","title":{"rendered":"FTP\u4e0b\u8f7dShell\u811a\u672c\u7f16\u7a0b"},"content":{"rendered":"<p>\u6211\u5fc3\u8840\u6765\u6f6e\u5b66\u8d77\u4e86Linux Shell\u811a\u672c\uff0c\u5927\u6982\u770b\u4e86\u4e00\u4e0b<a href=\"http:\/\/linux.vbird.org\/linux_basic\/0340bashshell-scripts.php\">\u9e1f\u54e5\u7684\u6559\u6750<\/a>\u4e2a\u4eba\u611f\u89c9\u4e0d\u9519\u3002\u521a\u597d\u624b\u5934\u6709\u4e2a\u9700\u6c42\uff0c\u5927\u81f4\u662f\u9700\u8981\u4eceFTP\u4e0b\u8f7dzip\u6587\u4ef6\u5e76\u89e3\u538b\u3002\u6211\u4e4b\u524d\u5199\u4e86\u4e2aPython\u7248\u672c\uff0c\u6b63\u597d\u7528Shell\u811a\u672c\u91cd\u5199\u4e00\u904d\u7ec3\u7ec3\u624b:)\u3002<\/p>\n<pre><code>#!\/bin\/sh\n# download file from ftp server.\n# write by bobo\n\nVERSION=1.0\n\nif [ \"$#\" != \"3\" ]; then\n    echo \"Version $VERSION\"\n    echo \"Usage:\"\n    echo \"    ftp.sh username@ip password files\"\n    exit 1\nfi\n\nusername=$(echo $1 | cut -d'@' -f 1)\nif [ ! \"$username\" ]; then\n    echo \"username invalid\" \n    exit 1\nfi\n\nip=$(echo $1 | cut -d'@' -f 2)\nif [ ! \"$ip\" ]; then\n    echo \"ip invalid\" \n    exit 1\nfi\n\npassword=$2\nfile=$3\n\n#echo $username,$ip,$password,$file\n\n#ftp -inv $ip &lt;&lt;EOF\nftp -in $ip &lt;&lt;EOF\nuser $username $password\nbin\nget $file\nbye\nEOF\n\nif [ -e \"$file\" ]; then\n    echo \"download success\"\n\n    dirname=$(echo $file | cut -d'.' -f 1)\n    filetype=$(echo $file | cut -d'.' -f 2)\n\n    # the file type is zip?\n    if [ \"$filetype\" = \"zip\" ]; then\n        mkdir -p $dirname\n        unzip -o $file -d $dirname\n    fi\nfi \n<\/code><\/pre>\n<p>\u793a\u4f8b\uff1a\u4eceftp\u670d\u52a1\u5668192.168.14.1\u4e0a\u4e0b\u8f7d14.zip\u5e76\u89e3\u538b\uff1a<\/p>\n<pre><code>ftp.sh username@192.168.14.1 password 14.zip\n<\/code><\/pre>\n<p>\u8bb0\u5f55\u4e00\u4e0b\u5fc3\u5f97\uff1a<\/p>\n<ul>\n<li>ftp\u547d\u4ee4\u53c2\u6570-n\u8868\u793a\u767b\u5f55\u65f6\u4e0d\u8fdb\u884c\u7528\u6237\u5bc6\u7801\u9a8c\u8bc1\uff0c\u53ef\u4ee5\u7528user\u547d\u4ee4\u8f93\u5165\u7528\u6237\u548c\u5bc6\u7801\uff0c\u65b9\u4fbf\u811a\u672c\u7f16\u5199\u3002<\/li>\n<li>&lt;&lt;EOF\u8868\u793a\u952e\u76d8\u8f93\u5165\u5230EOF\u4e3a\u6b62\uff0c\u8fd9\u6837\u811a\u672c\u4e2d\u53ea\u8981\u6bcf\u884c\u8f93\u5165FTP\u547d\u4ee4\uff0c\u6700\u540e\u4ee5EOF\u7ed3\u675f\u5c31\u884c\u4e86\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u5fc3\u8840\u6765\u6f6e\u5b66\u8d77\u4e86Linux Shell\u811a\u672c\uff0c\u5927\u6982\u770b\u4e86\u4e00\u4e0b\u9e1f\u54e5\u7684\u6559\u6750\u4e2a\u4eba\u611f\u89c9\u4e0d\u9519\u3002 &hellip; <a href=\"https:\/\/bl4kraven.com\/index.php\/2012\/05\/11\/ftp%e4%b8%8b%e8%bd%bdshell%e8%84%9a%e6%9c%ac%e7%bc%96%e7%a8%8b\/\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a> <a href=\"https:\/\/bl4kraven.com\/index.php\/2012\/05\/11\/ftp%e4%b8%8b%e8%bd%bdshell%e8%84%9a%e6%9c%ac%e7%bc%96%e7%a8%8b\/\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-110","post","type-post","status-publish","format-standard","hentry","category-program"],"_links":{"self":[{"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/posts\/110","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/comments?post=110"}],"version-history":[{"count":0,"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/posts\/110\/revisions"}],"wp:attachment":[{"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/media?parent=110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/categories?post=110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bl4kraven.com\/index.php\/wp-json\/wp\/v2\/tags?post=110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}