{"id":33,"date":"2024-03-10T22:05:00","date_gmt":"2024-03-10T14:05:00","guid":{"rendered":"http:\/\/175.178.247.106\/?p=33"},"modified":"2025-03-03T10:07:49","modified_gmt":"2025-03-03T02:07:49","slug":"linux-bin%e6%96%87%e4%bb%b6%e7%9a%84%e5%88%b6%e4%bd%9c","status":"publish","type":"post","link":"http:\/\/175.178.247.106\/index.php\/2024\/03\/10\/linux-bin%e6%96%87%e4%bb%b6%e7%9a%84%e5%88%b6%e4%bd%9c\/","title":{"rendered":"Linux bin\u6587\u4ef6\u7684\u5236\u4f5c"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p id=\"u48b655bd\">\u5728\u67d0\u4e9b\u573a\u666f\u4e0b\uff0c\u6211\u4eec\u5e0c\u671b\u5c06\u4e00\u7cfb\u5217\u5b89\u88c5\u7684\u52a8\u4f5c\u6253\u5305\u5728\u4e00\u4e2a <code>.bin<\/code>\u6587\u4ef6\u91cc\u9762\uff0c\u5728\u65b0\u7684\u73af\u5883\u5b89\u88c5\u90e8\u7f72\u65f6\uff0c\u76f4\u63a5\u4f7f\u7528 .bin \u6587\u4ef6\u6765\u65e0\u8111\u90e8\u7f72\u3002\u8fd9\u65f6\u5019\u5c31\u53ef\u4ee5\u5c06\u5b89\u88c5\u6240\u9700\u8981\u7684\u6b65\u9aa4\u548c\u6587\u4ef6\u6253\u5305\u6210\u4e00\u4e2a <code>.bin<\/code> \u6587\u4ef6\uff0c\u5728\u65b0\u670d\u52a1\u5668\u4e0a\u6267\u884c <code>.\/xxx.bin<\/code> \u6765\u8fdb\u884c\u65e0\u8111\u5b89\u88c5\u3002<\/p>\n\n\n\n<p id=\"u2beb192b\">\u8981\u505a\u5230\u5c06\u4e00\u4e9b\u5217\u7684\u6587\u4ef6\u5408\u5e76\u5230\u4e00\u4e2a\u6587\u4ef6\u4e2d\uff0c\u7b2c\u4e00\u60f3\u5230\u7684\u5c31\u662f tar \u547d\u4ee4\uff0c\u8981\u4f7f\u5f97 .\/bin \u80fd\u8fd0\u884c\uff0c\u90a3\u4e48\u5c31\u8981\u7528\u5230\u811a\u672c\u6587\u4ef6\u4e86\u3002\u5c06\u811a\u672c\u5185\u5bb9\u653e\u5230\u6587\u4ef6\u7684\u9876\u90e8\u3002\u540e\u9762\u7684\u6587\u4ef6\u653e\u5de5\u7a0b\u6587\u4ef6\uff0cbin \u7684\u65f6\u5019\uff0c\u5934\u90e8\u811a\u672c\u5c06\u5de5\u7a0b\u6587\u4ef6\u8131\u843d\uff0c\u8131\u843d\u4e4b\u540e\uff0c\u8fd0\u884c\u5de5\u7a0b\u6587\u4ef6\u4e2d\u7684\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u8ba9\u8fd9\u4e2a\u7a0b\u5e8f\u6765\u63a7\u5236\u5de5\u7a0b\u6587\u4ef6\u7684\u90e8\u7f72\u3002<\/p>\n\n\n\n<p id=\"ub87076fe\">\u6587\u4ef6\u7ed3\u6784\u5982\u4e0b\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"392\" height=\"385\" src=\"http:\/\/175.178.247.106\/wp-content\/uploads\/2025\/03\/image.png\" alt=\"\" class=\"wp-image-34\" srcset=\"http:\/\/175.178.247.106\/wp-content\/uploads\/2025\/03\/image.png 392w, http:\/\/175.178.247.106\/wp-content\/uploads\/2025\/03\/image-300x295.png 300w, http:\/\/175.178.247.106\/wp-content\/uploads\/2025\/03\/image-275x270.png 275w\" sizes=\"auto, (max-width: 392px) 100vw, 392px\" \/><\/figure>\n\n\n\n<p id=\"u539d4255\">\u8981\u5236\u4f5c\u8fd9\u6837\u7684 bin \u6587\u4ef6\uff0c\u6211\u4eec\u5148\u8981\u6709\u4e2a package.sh \u811a\u672c\uff0c\u6765\u5c06\u8fd9\u6837\u7684\u5934\u90e8\u6587\u4ef6\u548c\u5de5\u7a0b\u6587\u4ef6\u5408\u5e76\u3002\u5047\u5982\u5de5\u7a0b\u6587\u4ef6\u76ee\u5f55\u4e3a project.<\/p>\n\n\n\n<p id=\"uc6522d96\">header.sh<\/p>\n\n\n\n<p id=\"u3b3dd4bd\">project<\/p>\n\n\n\n<p id=\"u2baf55af\">package.sh \u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre id=\"Zrpj1\" class=\"wp-block-code\"><code>#!\/bin\/bash\n\ntar zcvf project.tar.gz project\n\ncat header.sh project.tar.gz &gt;&gt;  result.bin\n\nchmod a+x result.bin<\/code><\/pre>\n\n\n\n<p id=\"ud536ed44\">.\/package.sh \u4e4b\u540e\uff0c\u5f97\u5230 result.bin \u6587\u4ef6<\/p>\n\n\n\n<p id=\"ucbfc46ef\">header.sh \u88ab\u653e\u5728\u4e86 result.bin \u6587\u4ef6\u7684\u5934\u90e8<\/p>\n\n\n\n<p id=\"u1ffb1291\">\u73b0\u5728\u5c31\u662f\u8981\u5b9e\u73b0 header.sh \u7684\u903b\u8f91\u4e86\u3002<\/p>\n\n\n\n<p id=\"u66e6dcb5\">header.sh \u7684\u903b\u8f91\uff0c\u7b2c\u4e00\u8981\u5c06 project.tar.gz \u4ece result.bin \u4e2d\u8fdb\u884c\u5206\u79bb\u51fa\u6765\u3002<\/p>\n\n\n\n<p id=\"u51eba788\">\u7b2c\u4e8c\uff0c\u89e3\u538b project.tar.gz<\/p>\n\n\n\n<p id=\"ud38f9705\">\u7b2c\u4e09\uff0c\u8fd0\u884c project \u4e2d\u7684\u7b2c\u4e00\u4e2a\u811a\u672c<\/p>\n\n\n\n<p id=\"ue71afbdd\">\u540e\u9762\u4e24\u7b80\u5355\u3002<\/p>\n\n\n\n<p id=\"ue83a5d8b\">\u5173\u952e\u7b2c\u4e00\u6b65\uff0c\u600e\u4e48\u77e5\u9053\u8981\u4ece result.bin \u4e2d\u53d6\u591a\u5c11\u5b57\u8282\u51fa\u6765\u5462\uff0c\u5f88\u7b80\u5355\u5c31\u662f\u5728 tar project \u5b8c\u8ba1\u7b97\u5927\u5c0f\uff0c\u5199\u5165\u5230 header.sh \u4e2d\u3002<\/p>\n\n\n\n<p id=\"uad74a05f\">\u6240\u4ee5\uff0c\u6211\u4eec\u518d\u6539\u4e0b package.sh \u811a\u672c\u3002<\/p>\n\n\n\n<pre id=\"gEgfs\" class=\"wp-block-code\"><code>#!\/bin\/bash\n\ntar zcvf project.tar.gz project\n\nfilesize=$(wc -c &lt; project.tar.gz)\n\ncp header.sh header-bak.sh\n                   \nsed -i  \"s\/TAR_SIZE\/${filesize}\/g\"  header-bak.sh\n\n\ncat header-bak.sh project.tar.gz &gt;  result.bin\n\nchmod a+x result.bin\n<\/code><\/pre>\n\n\n\n<p id=\"u1c9ebb72\">filesize=$(wc -c &lt; project.tar.gz)<\/p>\n\n\n\n<p id=\"u84bd8057\">sed -i &#8220;s\/TAR_SIZE\/${filesize}\/g&#8221; header-bak.sh<\/p>\n\n\n\n<p id=\"ub9da7dbf\">\u8fd9\u4e24\u884c\uff0c\u7b2c\u4e00\u884c\u662f\u83b7\u53d6\u5de5\u7a0b\u76ee\u5f55\u6253\u5305\u540e\u7684\u6587\u4ef6\u5927\u5c0f\uff0c\u7b2c\u4e8c\u884c\u5c31\u662f\u5c06\u8fd9\u4e2a\u6587\u4ef6\u7684\u5927\u5c0f\u5199\u5165\u5230 bin \u5305\u7684\u5934\u90e8\uff0c\u6211\u4eec\u56fa\u5b9a\u7684\u4e00\u4e2a\u53d8\u91cf\u540d\u4e2d\u3002<\/p>\n\n\n\n<p id=\"ue320bc0a\">\u6211\u4eec\u6765\u770b\u4e0b header.sh \u811a\u672c\u7684\u5185\u5bb9\u3002<\/p>\n\n\n\n<pre id=\"O5mwJ\" class=\"wp-block-code\"><code>#!\/bin\/bash\n\ntarsize=TAR_SIZE\n\nworkdir=\"www.jesson32.cn\"\n\ntail -c ${tarsize} $0  &gt; ${workdir}.tar.gz\n\nmkdir \"${workdir}\"\ntar zxvf tmp.tar.gz -C \"${workdir}\"\ncd \"${workdir}\"\/project\n\n\nchmod u+x first.sh\n.\/first.sh\n\nexit\n<\/code><\/pre>\n\n\n\n<p id=\"u9701abec\">\u8fd9\u91cc\u7684 TAR_SIZE \u5c31\u662f\u5728 package.sh \u7684\u65f6\u5019\u5c31\u8fdb\u884c\u4e86\u66ff\u6362\uff0c\u540e\u7eed\u5c31\u662f\u4ece\u5f53\u524d bin \u5305\u4e2d\u83b7\u53d6\u5230 $TAR_SIZE \u5927\u5c0f\u7684\u5185\u5bb9\u751f\u6210\u4e00\u4e2a tar.gz \uff0c \u540e\u9762\u5c31\u662f\u89e3\u5f00\u8fd9\u4e2a tar.gz \u7136\u540e\u8fd0\u884c\u91cc\u9762\u9884\u8bbe\u597d\u7684 first.sh \u811a\u672c\u4e86\u3002<\/p>\n\n\n\n<pre id=\"W6R09\" class=\"wp-block-code\"><code>he@ubuntu:~\/jesson\/TestPackage$ ll project\n\u603b\u7528\u91cf 12\ndrwxrwxr-x 2 he he 4096 3\u6708   3 09:14 .\/\ndrwxrwxr-x 3 he he 4096 3\u6708   3 09:19 ..\/\n-rw-rw-r-- 1 he he   30 3\u6708   3 09:14 first.sh\n-rw-rw-r-- 1 he he    0 3\u6708   3 09:14 test.txt\n<\/code><\/pre>\n\n\n\n<p id=\"u62d8c0a1\">\u8fd9\u91cc\u4e3a\u4e86\u6d4b\u8bd5 first.sh \u7684\u903b\u8f91\u5f88\u7b80\u5355\uff0c\u5c31\u662f\u5c06 test.txt \u62f7\u8d1d\u5230 ~ \u76ee\u5f55\uff0c\u8fd9\u91cc first.sh \u5c31\u662f\u7528\u6237\u7684\u903b\u8f91\u811a\u672c\u4e86\uff0c\u540e\u9762\u8981\u505a\u7684\u5185\u5bb9\uff0c\u5c31\u53ef\u4ee5\u5f88\u968f\u610f\u4e86\u3002<\/p>\n\n\n\n<pre id=\"y9jJF\" class=\"wp-block-code\"><code>#!\/bin\/bash\n\ncp .\/test.txt ~\/\n<\/code><\/pre>\n\n\n\n<p id=\"u2cf7c07e\">\u540e\u7eed\uff1a<\/p>\n\n\n\n<p id=\"u073333c4\">\u540e\u9762\u5404\u79cd\u7684\u81ea\u5b9a\u4e49\u884c\u4e3a\uff0c\u90fd\u53ef\u4ee5\u5728 first.sh \u4e2d\u505a\uff0c\u6bd4\u5982\u589e\u52a0\u5404\u79cd\u5b89\u88c5\u9009\u9879\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u67d0\u4e9b\u573a\u666f\u4e0b\uff0c\u6211\u4eec\u5e0c\u671b\u5c06\u4e00\u7cfb\u5217\u5b89\u88c5\u7684\u52a8\u4f5c\u6253\u5305\u5728\u4e00\u4e2a .bin\u6587\u4ef6\u91cc\u9762\uff0c\u5728\u65b0\u7684\u73af\u5883\u5b89\u88c5\u90e8\u7f72\u65f6\uff0c\u76f4\u63a5\u4f7f\u7528 .bin \u6587\u4ef6\u6765\u65e0\u8111\u90e8\u7f72\u3002\u8fd9\u65f6\u5019\u5c31\u53ef\u4ee5\u5c06\u5b89\u88c5\u6240\u9700\u8981\u7684\u6b65\u9aa4\u548c&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"http:\/\/175.178.247.106\/index.php\/2024\/03\/10\/linux-bin%e6%96%87%e4%bb%b6%e7%9a%84%e5%88%b6%e4%bd%9c\/\"> Read More<span class=\"screen-reader-text\">  Read More<\/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":[12],"tags":[],"class_list":["post-33","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"http:\/\/175.178.247.106\/index.php\/wp-json\/wp\/v2\/posts\/33","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/175.178.247.106\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/175.178.247.106\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/175.178.247.106\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/175.178.247.106\/index.php\/wp-json\/wp\/v2\/comments?post=33"}],"version-history":[{"count":1,"href":"http:\/\/175.178.247.106\/index.php\/wp-json\/wp\/v2\/posts\/33\/revisions"}],"predecessor-version":[{"id":35,"href":"http:\/\/175.178.247.106\/index.php\/wp-json\/wp\/v2\/posts\/33\/revisions\/35"}],"wp:attachment":[{"href":"http:\/\/175.178.247.106\/index.php\/wp-json\/wp\/v2\/media?parent=33"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/175.178.247.106\/index.php\/wp-json\/wp\/v2\/categories?post=33"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/175.178.247.106\/index.php\/wp-json\/wp\/v2\/tags?post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}