{"id":20,"date":"2015-05-01T14:46:07","date_gmt":"2015-05-01T06:46:07","guid":{"rendered":"http:\/\/zfframework.com\/blog\/?p=20"},"modified":"2019-08-26T15:24:14","modified_gmt":"2019-08-26T07:24:14","slug":"android-%e9%82%a3%e8%9b%8b%e7%96%bc%e7%9a%84-shell","status":"publish","type":"post","link":"http:\/\/zsaber.com\/blog\/p\/20","title":{"rendered":"Android \u90a3\u86cb\u75bc\u7684 shell"},"content":{"rendered":"<p>\u6700\u8fd1\u7ecf\u5e38\u9f13\u6363 Android \u7684 shell \u811a\u672c, \u5e0c\u671b\u80fd\u7b80\u5316\u5404\u79cd\u6e05\u7406, \u5907\u4efd\u548c\u6062\u590d\u64cd\u4f5c\u7b49\u7b49, \u4e8e\u662f\u9047\u5230\u4e86\u5404\u79cd\u5404\u6837\u7684\u86cb\u75bc\u95ee\u9898, \u59d1\u4e14\u7559\u4e2a\u6587\u7eaa\u5ff5\u4e00\u4e0b&#8230;<\/p>\n<p>shell \u5e38\u7528\u65b9\u5f0f (sh my_script.sh)<\/p>\n<ul>\n<li>PC \u7aef adb shell (\u7528\u7684 Android \u81ea\u5e26 shell, \u76ee\u524d\u7cfb\u7edf\u4e00\u822c\u662f\u8f6f\u94fe\u63a5\u5230 \/system\/bin\/toybox, \u5f88\u6e23\u7684\u4e00\u4e2a shell, \u5404\u79cd\u5947\u8469\u95ee\u9898\u5747\u6765\u6e90\u4e8e\u6b64)<\/li>\n<li>\u624b\u673a\u7aef\u4f7f\u7528\u7ec8\u7aef\u76f4\u63a5\u8fd0\u884c (\u7528\u7684\u7ec8\u7aef\u8f6f\u4ef6\u81ea\u5e26\u7684 shell, \u4e00\u822c\u662f\u5185\u7f6e\u7684 busybox, \u5927\u591a\u6570\u60c5\u51b5\u4e0b\u6ca1\u4ec0\u4e48\u95ee\u9898)<\/li>\n<li>\u624b\u673a\u7aef\u4f7f\u7528 Tasker &gt; Script &gt; Run Shell (\u9ed8\u8ba4\u7528\u7684 Android \u81ea\u5e26 shell, \u5efa\u8bae\u624b\u52a8\u6307\u5b9a\u4e3a\u522b\u7684, \u6bd4\u5982 busybox)<\/li>\n<\/ul>\n<p><b>\u61d2\u4eba\u7248\u5efa\u8bae<\/b>:<\/p>\n<ul>\n<li>\u88c5\u4e2a busybox<\/li>\n<li>Tasker \u6216\u8005 adb \u91cc\u9762\u8981\u7528 shell \u7684\u65f6\u5019, \u624b\u52a8\u6307\u5b9a PATH, \u6bd4\u5982<\/li>\n<\/ul>\n<pre><code class=\"language-sh\"># busybox \u9ed8\u8ba4\u88c5\u5728 \/system\/xbin\nPATH=\/system\/xbin sh myscript.sh<\/code><\/pre>\n<p>.<\/p>\n<p>\u86cb\u75bc\u95ee\u9898\u5217\u8868 (\u4ec5\u9488\u5bf9 Android \u81ea\u5e26\u7684\u6e23\u6e23 shell):<\/p>\n<ul>\n<li>\n<p><code>#!\/bin\/sh<\/code><\/p>\n<p>\u5728 Android \u4e0a\u4f3c\u4e4e\u65e0\u6548? \u53cd\u6b63\u6211\u4e0d\u7ba1\u5199\u5565\u90fd\u65e0\u7528, Android \u81ea\u8eab\u7684 sh \u4e3a \/system\/bin\/sh<\/p>\n<\/li>\n<li>\n<p>\u7a7a\u884c\u95ee\u9898<\/p>\n<p>\u672c\u6765\u7167\u7406\u8bf4 sh \u811a\u672c\u53ef\u4ee5\u52a0\u4efb\u610f\u7a7a\u884c\u7684, \u4f46\u662f\u5728\u6211\u8fd9, \u5982\u679c\u7528 adb shell \u6216\u624b\u673a\u7ec8\u7aef, \u7a7a\u884c\u4e4b\u540e\u7684\u8bed\u53e5\u5c31\u5168\u90e8\u4e0d\u6267\u884c\u4e86, \u800c\u7528 Tasker \u5c31\u53ef\u4ee5 &#8211; &#8211;<\/p>\n<\/li>\n<li>\n<p>su<\/p>\n<p>\u66f4\u52a0\u65e0\u8bed\u7684\u95ee\u9898, \u5982\u679c\u4ee5 root \u8eab\u4efd\u6267\u884c sh \u811a\u672c, \u800c sh \u811a\u672c\u91cc\u9762\u53c8\u5305\u542b\u4e86 su \u8bed\u53e5, \u5219\u4e4b\u540e\u7684\u8bed\u53e5\u53c8\u65e0\u6548\u4e86&#8230; \u4f9d\u65e7, \u53ea\u5728 adb shell \u548c \u624b\u673a\u7ec8\u7aef\u4e2d\u51fa\u73b0, Tasker \u4e00\u5207\u6b63\u5e38<\/p>\n<\/li>\n<li>\n<p>\u6743\u9650<\/p>\n<p>\u53c8\u4e00\u4e2a\u975e\u5e38\u60f3\u95ee\u5019 Android \u7956\u5b97\u7684\u95ee\u9898, \u8bbe\u8ba1\u8005\u7684\u8111\u95e8\u7edd\u5bf9\u88ab\u95e8\u5939\u8fc7: SD \u5361\u6587\u4ef6\u9ed8\u8ba4\u6743\u9650\u4e3a 075 (\u6587\u4ef6\u6240\u6709\u8005\u65e0\u4efb\u4f55\u6743\u9650)<\/p>\n<p>\u603b\u4e4b, \u5982\u679c\u4ece SD \u5361\u590d\u5236\u6587\u4ef6\u5230\u7cfb\u7edf\u76ee\u5f55, \u6743\u9650\u8fd8\u4f1a\u4fdd\u6301 075 \u72b6\u6001, \u5e76\u4e14\u5982\u679c\u662f\u8fde\u540c\u6587\u4ef6\u5939\u590d\u5236\u7684, \u76ee\u6807\u6587\u4ef6\u5939\u4e5f\u4f1a\u56e0\u6b64\u53d8\u4e3a 075, \u5fc5\u987b\u53e6\u884c chmod, \u7136\u540e, \u53c8\u5f15\u51fa\u4e86 chmod \u7684\u86cb\u75bc\u95ee\u9898<\/p>\n<\/li>\n<li>\n<p><code>chmod -R<\/code><\/p>\n<p>\u591a\u4e2a\u9012\u5f52\u529f\u80fd\u4f1a\u6b7b\u554a? \u53cd\u6b63 Android \u7684 chmod \u662f\u4e0d\u652f\u6301\u9012\u5f52\u7684, \u8981\u80bf\u4e48\u641e\u5462? \u4f60\u5f97\u86cb\u75bc\u65e0\u6bd4\u7684\u7528\u6b64\u65b9\u5f0f:<\/p>\n<pre><code class=\"language-sh\">find \/path_to_chmod | while read f; do chmod 755 $f; done<\/code><\/pre>\n<p>\u6216\u8005\u66f4\u52a0\u86cb\u75bc\u65e0\u6bd4\u7684\u653e\u5f03\u9012\u5f52, \u624b\u52a8\u5bf9\u6bcf\u4e2a\u6587\u4ef6 chmod&#8230;<\/p>\n<\/li>\n<li>\n<p><code>ln<\/code><\/p>\n<p>\u7b26\u53f7\u94fe\u63a5\u672c\u6765\u662f\u4e2a\u5f88\u5e05\u6c14\u7684\u4e1c\u897f, \u5230 Android \u4e0a\u53c8\u4e0d\u5e05\u4e86, \u6bd4\u5982:<\/p>\n<pre><code class=\"language-sh\">rm -r \/tmp\/*\n# rm failed for \/tmp\/*, No such file or directory<\/code><\/pre>\n<p>\u4e3a\u5565\u5462, \u56e0\u4e3a Android \u4e0a\u7684 \/tmp \u88ab\u94fe\u63a5\u5230 \/data\/tmp, \u800c\u975e\u6587\u4ef6\u5939, \u800c Android \u7684 rm \u53d1\u73b0 tmp \u662f\u4e2a\u7b26\u53f7\u94fe\u63a5\u6587\u4ef6\u5c31\u8ba4\u4e3a\u6ca1\u6709 \/tmp \u8fd9\u4e2a\u76ee\u5f55\u4e86, \u4e8e\u662f\u4f60\u5f97\u8fd9\u4e48\u5e72:<\/p>\n<pre><code class=\"language-sh\">cd \/tmp\nrm -r .\/*<\/code><\/pre>\n<\/li>\n<\/ul>\n<p>over<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u7ecf\u5e38\u9f13\u6363 Android \u7684 shell \u811a\u672c, \u5e0c\u671b\u80fd\u7b80\u5316\u5404\u79cd\u6e05\u7406, \u5907\u4efd\u548c\u6062\u590d\u64cd\u4f5c\u7b49\u7b49, \u4e8e\u662f\u9047\u5230\u4e86\u5404\u2026 <span class=\"read-more\"><a href=\"http:\/\/zsaber.com\/blog\/p\/20\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Android \u90a3\u86cb\u75bc\u7684 shell - \u67d0Z\u7684\u535a\u5ba2<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/zsaber.com\/blog\/p\/20\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android \u90a3\u86cb\u75bc\u7684 shell - \u67d0Z\u7684\u535a\u5ba2\" \/>\n<meta property=\"og:description\" content=\"\u6700\u8fd1\u7ecf\u5e38\u9f13\u6363 Android \u7684 shell \u811a\u672c, \u5e0c\u671b\u80fd\u7b80\u5316\u5404\u79cd\u6e05\u7406, \u5907\u4efd\u548c\u6062\u590d\u64cd\u4f5c\u7b49\u7b49, \u4e8e\u662f\u9047\u5230\u4e86\u5404\u2026 Read More &raquo;\" \/>\n<meta property=\"og:url\" content=\"http:\/\/zsaber.com\/blog\/p\/20\" \/>\n<meta property=\"og:site_name\" content=\"\u67d0Z\u7684\u535a\u5ba2\" \/>\n<meta property=\"article:published_time\" content=\"2015-05-01T06:46:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-08-26T07:24:14+00:00\" \/>\n<meta name=\"author\" content=\"Z\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"Z\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/zsaber.com\/blog\/p\/20#article\",\"isPartOf\":{\"@id\":\"http:\/\/zsaber.com\/blog\/p\/20\"},\"author\":{\"name\":\"Z\",\"@id\":\"http:\/\/zsaber.com\/blog\/#\/schema\/person\/6a6701fc719eff087e24e39a00e2280f\"},\"headline\":\"Android \u90a3\u86cb\u75bc\u7684 shell\",\"datePublished\":\"2015-05-01T06:46:07+00:00\",\"dateModified\":\"2019-08-26T07:24:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/zsaber.com\/blog\/p\/20\"},\"wordCount\":74,\"commentCount\":2,\"publisher\":{\"@id\":\"http:\/\/zsaber.com\/blog\/#\/schema\/person\/6a6701fc719eff087e24e39a00e2280f\"},\"articleSection\":[\"Android\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\/\/zsaber.com\/blog\/p\/20#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/zsaber.com\/blog\/p\/20\",\"url\":\"http:\/\/zsaber.com\/blog\/p\/20\",\"name\":\"Android \u90a3\u86cb\u75bc\u7684 shell - \u67d0Z\u7684\u535a\u5ba2\",\"isPartOf\":{\"@id\":\"http:\/\/zsaber.com\/blog\/#website\"},\"datePublished\":\"2015-05-01T06:46:07+00:00\",\"dateModified\":\"2019-08-26T07:24:14+00:00\",\"breadcrumb\":{\"@id\":\"http:\/\/zsaber.com\/blog\/p\/20#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/zsaber.com\/blog\/p\/20\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/zsaber.com\/blog\/p\/20#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"http:\/\/zsaber.com\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android \u90a3\u86cb\u75bc\u7684 shell\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/zsaber.com\/blog\/#website\",\"url\":\"http:\/\/zsaber.com\/blog\/\",\"name\":\"\u67d0Z\u7684\u535a\u5ba2\",\"description\":\"\u7b80\u4ecb\u53c8\u4e0d\u80fd\u5403\",\"publisher\":{\"@id\":\"http:\/\/zsaber.com\/blog\/#\/schema\/person\/6a6701fc719eff087e24e39a00e2280f\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/zsaber.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\/\/zsaber.com\/blog\/#\/schema\/person\/6a6701fc719eff087e24e39a00e2280f\",\"name\":\"Z\",\"logo\":{\"@id\":\"http:\/\/zsaber.com\/blog\/#\/schema\/person\/image\/\"},\"description\":\"\u67d0Z\",\"sameAs\":[\"http:\/\/ZFFramework.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android \u90a3\u86cb\u75bc\u7684 shell - \u67d0Z\u7684\u535a\u5ba2","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/zsaber.com\/blog\/p\/20","og_locale":"zh_CN","og_type":"article","og_title":"Android \u90a3\u86cb\u75bc\u7684 shell - \u67d0Z\u7684\u535a\u5ba2","og_description":"\u6700\u8fd1\u7ecf\u5e38\u9f13\u6363 Android \u7684 shell \u811a\u672c, \u5e0c\u671b\u80fd\u7b80\u5316\u5404\u79cd\u6e05\u7406, \u5907\u4efd\u548c\u6062\u590d\u64cd\u4f5c\u7b49\u7b49, \u4e8e\u662f\u9047\u5230\u4e86\u5404\u2026 Read More &raquo;","og_url":"http:\/\/zsaber.com\/blog\/p\/20","og_site_name":"\u67d0Z\u7684\u535a\u5ba2","article_published_time":"2015-05-01T06:46:07+00:00","article_modified_time":"2019-08-26T07:24:14+00:00","author":"Z","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"Z","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/zsaber.com\/blog\/p\/20#article","isPartOf":{"@id":"http:\/\/zsaber.com\/blog\/p\/20"},"author":{"name":"Z","@id":"http:\/\/zsaber.com\/blog\/#\/schema\/person\/6a6701fc719eff087e24e39a00e2280f"},"headline":"Android \u90a3\u86cb\u75bc\u7684 shell","datePublished":"2015-05-01T06:46:07+00:00","dateModified":"2019-08-26T07:24:14+00:00","mainEntityOfPage":{"@id":"http:\/\/zsaber.com\/blog\/p\/20"},"wordCount":74,"commentCount":2,"publisher":{"@id":"http:\/\/zsaber.com\/blog\/#\/schema\/person\/6a6701fc719eff087e24e39a00e2280f"},"articleSection":["Android"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/zsaber.com\/blog\/p\/20#respond"]}]},{"@type":"WebPage","@id":"http:\/\/zsaber.com\/blog\/p\/20","url":"http:\/\/zsaber.com\/blog\/p\/20","name":"Android \u90a3\u86cb\u75bc\u7684 shell - \u67d0Z\u7684\u535a\u5ba2","isPartOf":{"@id":"http:\/\/zsaber.com\/blog\/#website"},"datePublished":"2015-05-01T06:46:07+00:00","dateModified":"2019-08-26T07:24:14+00:00","breadcrumb":{"@id":"http:\/\/zsaber.com\/blog\/p\/20#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["http:\/\/zsaber.com\/blog\/p\/20"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/zsaber.com\/blog\/p\/20#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"http:\/\/zsaber.com\/blog"},{"@type":"ListItem","position":2,"name":"Android \u90a3\u86cb\u75bc\u7684 shell"}]},{"@type":"WebSite","@id":"http:\/\/zsaber.com\/blog\/#website","url":"http:\/\/zsaber.com\/blog\/","name":"\u67d0Z\u7684\u535a\u5ba2","description":"\u7b80\u4ecb\u53c8\u4e0d\u80fd\u5403","publisher":{"@id":"http:\/\/zsaber.com\/blog\/#\/schema\/person\/6a6701fc719eff087e24e39a00e2280f"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/zsaber.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"http:\/\/zsaber.com\/blog\/#\/schema\/person\/6a6701fc719eff087e24e39a00e2280f","name":"Z","logo":{"@id":"http:\/\/zsaber.com\/blog\/#\/schema\/person\/image\/"},"description":"\u67d0Z","sameAs":["http:\/\/ZFFramework.com"]}]}},"_links":{"self":[{"href":"http:\/\/zsaber.com\/blog\/wp-json\/wp\/v2\/posts\/20"}],"collection":[{"href":"http:\/\/zsaber.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/zsaber.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/zsaber.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/zsaber.com\/blog\/wp-json\/wp\/v2\/comments?post=20"}],"version-history":[{"count":0,"href":"http:\/\/zsaber.com\/blog\/wp-json\/wp\/v2\/posts\/20\/revisions"}],"wp:attachment":[{"href":"http:\/\/zsaber.com\/blog\/wp-json\/wp\/v2\/media?parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/zsaber.com\/blog\/wp-json\/wp\/v2\/categories?post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/zsaber.com\/blog\/wp-json\/wp\/v2\/tags?post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}