{"id":534,"date":"2018-08-13T15:24:00","date_gmt":"2018-08-13T15:24:00","guid":{"rendered":"http:\/\/www.liutianfeng.com\/?p=534"},"modified":"2019-12-11T03:33:00","modified_gmt":"2019-12-11T03:33:00","slug":"shell%e8%84%9a%e6%9c%ac%e7%bc%96%e8%af%91%e6%88%90%e4%ba%8c%e8%bf%9b%e5%88%b6%e7%9a%84%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.liutianfeng.com\/?p=534","title":{"rendered":"shell\u811a\u672c\u7f16\u8bd1\u6210\u4e8c\u8fdb\u5236\u7684\u65b9\u6cd5"},"content":{"rendered":"<p>\u4f5c\u4e3a\u7a0b\u5e8f\u5458, \u80fd\u505a\u5f00\u6e90\u9879\u76ee\u80af\u5b9a\u662f\u4e00\u79cd\u8363\u8000.<\/p>\n<p>\u4f46\u5982\u679c\u81ea\u5df1\u7684\u4e1c\u897f\u5b9e\u5728\u4e0d\u597d\u610f\u601d\u5f00\u6e90, \u6216\u8005\u5b58\u6709\u4e00\u70b9\u70b9\u79c1\u5fc3\u7684\u8bdd, \u5c06\u81ea\u5df1\u7684\u811a\u672c\u5c01\u88c5\u6210\u4e8c\u8fdb\u5236, \u4e5f\u662f\u5bf9\u8fdc\u5417\u7684\u4e00\u79cd\u4fdd\u62a4.<\/p>\n<p>\u4e0b\u9762, \u4ecb\u7ecd\u4e00\u4e0b\u7f16\u8bd1shell\u811a\u672c\u7684\u65b9\u6cd5.<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">lius@suse12:tmp&gt; cat lius.sh \r\n#!\/bin\/bash\r\necho OK!<\/code><\/pre>\n<p><strong>\u7f16\u8bd1\u751f\u6210\u4e8c\u8fdb\u5236:<\/strong><\/p>\n<p>\u6240\u7528\u5230\u7684\u547d\u4ee4: shc\uff08\u6ca1\u6709\u547d\u4ee4\uff0c\u9700\u8981yum\u6216\u8005rpm\u5b89\u88c5\uff09<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">lius@suse12:bin&gt; shc --help\r\nshc: invalid option -- '-'\r\nshc parse: Unknown option\r\nshc Version 3.9.6, Generic Shell Script Compiler\r\nshc GNU GPL Version 3 Md Jahidul Hamid &lt;jahidulhamid@yahoo.com&gt;\r\nshc Usage: shc [-e date] [-m addr] [-i iopt] [-x cmnd] [-l lopt] [-o outfile] [-rvDUCABh] -f script\r\n\r\n    -e %s  Expiration date in dd\/mm\/yyyy format [none]\r\n    -m %s  Message to display upon expiration [\"Please contact your provider\"]\r\n    -f %s  File name of the script to compile\r\n    -i %s  Inline option for the shell interpreter i.e: -e\r\n    -x %s  eXec command, as a printf format i.e: exec('%s',@ARGV);\r\n    -l %s  Last shell option i.e: --\r\n    -o %s  output filename\r\n    -r     Relax security. Make a redistributable binary\r\n    -v     Verbose compilation\r\n    -D     Switch ON debug exec calls [OFF]\r\n    -U     Make binary untraceable [no]\r\n    -C     Display license and exit\r\n    -A     Display abstract and exit\r\n    -B     Compile for busybox\r\n    -h     Display help and exit\r\n\r\n    Environment variables used:\r\n    Name    Default  Usage\r\n    CC      cc       C compiler command\r\n    CFLAGS  &lt;none&gt;   C compiler flags\r\n\r\n    Please consult the shc man page.<\/code><\/pre>\n<p><strong>\u5e38\u7528\u9009\u9879:<\/strong><\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">-v: \u8be6\u7ec6\u6a21\u5f0f, \u6253\u5370\u4fe1\u606f\u8be6\u7ec6, \u4fbf\u4e8e\u67e5\u770b\u8fdb\u7a0b;\r\n-r: \u652f\u6301\u591a\u7cfb\u7edf\u6267\u884c\u7684\u4e00\u79cd\u4e8c\u8fdb\u5236\u7f16\u8bd1\u683c\u5f0f;\r\n-f: \u8ddf\u8981\u7f16\u8bd1\u7684shell\u811a\u672c\u540d\u79f0;<\/code><\/pre>\n<p><strong>\u7f16\u8bd1\u8fc7\u7a0b:<\/strong><\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">lius@suse12:tmp&gt; shc -f lius.sh -v -r   \/\/ -f \u540e\u9762\u8ddfshell\u811a\u672c\u7684\u540d\u79f0, \u53ef\u4ee5\u653e\u5230\u53e5\u5b50\u4e2d\u95f4\r\nshc shll=bash   \/\/ \u540e\u9762\u662f\u6267\u884c\u8fc7\u7a0b\r\nshc [-i]=-c\r\nshc [-x]=exec '%s' \"$@\"\r\nshc [-l]=\r\nshc opts=\r\nshc: cc  lius.sh.x.c -o lius.sh.x\r\nshc: strip lius.sh.x\r\nshc: chmod ug=rwx,o=rx lius.sh.x\r\n\r\nlius@suse12:tmp&gt; ls lius*    \/\/ \u53ef\u4ee5\u770b\u5230\u751f\u6210\u7684\u4e24\u4e2a\u6587\u4ef6\r\nlius.sh  lius.sh.x  lius.sh.x.c\r\n\r\nlius@suse12:tmp&gt; file lius*   \/\/ \u67e5\u770b\u4ed6\u4eec\u7684\u6027\u8d28\r\nlius.sh:     Bourne-Again shell script, ASCII text executable   \/\/ \u6e90\u7801\r\nlius.sh.x:   ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU\/Linux 3.0.0, BuildID[sha1]=f2231a9fb3168396b211f41a9d88a577e1cc600c, stripped   \/\/ \u4e8c\u8fdb\u5236\r\nlius.sh.x.c: C source, ASCII text   \/\/ C \u6e90\u7801<\/code><\/pre>\n<p>\u6211\u4eec\u53ef\u4ee5\u5220\u9664\u4e4b\u524d\u7684\u6e90\u7801, \u5c06lius.sh.x\u547d\u540d\u6210lius.sh.<\/p>\n<p>\u6ce8\u610f, \u8fd9\u6837\u7684\u811a\u672c, \u5fc5\u987b\u8981\u6709Sha-Bang, \u4e0d\u7136\u7684\u8bdd\u6267\u884c\u65f6\u5019\u4f1a\u51fa\u9519.<\/p>\n<p><strong>\u6267\u884c\u7ed3\u679c:<\/strong><\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">lius@suse12:tmp&gt; .\/lius.sh.x  \r\nOK!<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1a<a href=\"https:\/\/www.liutianfeng.com\">liutianfeng.com<\/a> &raquo; <a href=\"https:\/\/www.liutianfeng.com\/?p=534\">shell\u811a\u672c\u7f16\u8bd1\u6210\u4e8c\u8fdb\u5236\u7684\u65b9\u6cd5<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u4e3a\u7a0b\u5e8f\u5458, \u80fd\u505a\u5f00\u6e90\u9879\u76ee\u80af\u5b9a\u662f\u4e00\u79cd\u8363\u8000. \u4f46\u5982\u679c\u81ea\u5df1\u7684\u4e1c\u897f\u5b9e\u5728\u4e0d\u597d\u610f\u601d\u5f00\u6e90, \u6216\u8005\u5b58\u6709\u4e00\u70b9\u70b9\u79c1\u5fc3\u7684\u8bdd, \u5c06\u81ea [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[31],"tags":[],"_links":{"self":[{"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/534"}],"collection":[{"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=534"}],"version-history":[{"count":3,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/534\/revisions"}],"predecessor-version":[{"id":716,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/534\/revisions\/716"}],"wp:attachment":[{"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=534"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=534"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=534"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}