{"id":144,"date":"2014-07-31T20:36:34","date_gmt":"2014-07-31T11:36:34","guid":{"rendered":"https:\/\/www.dogrow.net\/python\/?p=144"},"modified":"2019-10-19T08:31:21","modified_gmt":"2019-10-18T23:31:21","slug":"blog39","status":"publish","type":"post","link":"https:\/\/www.dogrow.net\/python\/blog39\/","title":{"rendered":"(39) \u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u30fb\u5b9f\u884c"},"content":{"rendered":"<p>\u307e\u305a\u521d\u3081\u306b\u3001\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb exec.sh \u3092\u4f5c\u6210\u3057\u3001\u5b9f\u884c\u5c5e\u6027\u3092\u4ed8\u4e0e\u3059\u308b\u3002<\/p>\n<pre>&gt;&gt;&gt; fh = <span class=\"my_fc_deeppinkB\">open<\/span>('exec.sh','w')\r\n&gt;&gt;&gt; fh.<span class=\"my_fc_deeppinkB\">write<\/span>('#!\/bin\/sh\\n')\r\n&gt;&gt;&gt; fh.<span class=\"my_fc_deeppinkB\">write<\/span>('export LD_LIBRARY_PATH=\/usr\/local\/lib\\n')\r\n&gt;&gt;&gt; fh.<span class=\"my_fc_deeppinkB\">write<\/span>('gcc --version\\n')\r\n&gt;&gt;&gt; fh.<span class=\"my_fc_deeppinkB\">write<\/span>('#end')\r\n&gt;&gt;&gt; fh.<span class=\"my_fc_deeppinkB\">close<\/span>()\r\n&gt;&gt;&gt;\r\n&gt;&gt;&gt; import subprocess as sp\r\n&gt;&gt;&gt; args = ['<span class=\"my_fc_redB\">chmod<\/span>','<span class=\"my_fc_redB\">+x<\/span>','<span class=\"my_fc_redB\">.\/exec.sh<\/span>']\r\n&gt;&gt;&gt; sp.<span class=\"my_fc_deeppinkB\">call<\/span>(args)\r\n0\r\n<\/pre>\n<p>\u4f5c\u6210\u3057\u305f\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u5b9f\u884c\u3059\u308b\u3002<\/p>\n<pre>&gt;&gt;&gt; import subprocess as sp\r\n&gt;&gt;&gt; args = ['<span class=\"my_fc_redB\">.\/exec.sh<\/span>']\r\n&gt;&gt;&gt; sp.<span class=\"my_fc_deeppinkB\">call<\/span>(args)\r\ngcc (GCC) 4.9.0\r\nCopyright (C) 2014 Free Software Foundation, Inc.\r\nThis is free software; see the source for copying conditions.  There is NO\r\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r\n\r\n0\r\n<\/pre>\n<hr class=\"my_hr_bottom\">\n","protected":false},"excerpt":{"rendered":"<p>\u307e\u305a\u521d\u3081\u306b\u3001\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb exec.sh \u3092\u4f5c\u6210\u3057\u3001\u5b9f\u884c\u5c5e\u6027\u3092\u4ed8\u4e0e\u3059\u308b\u3002 &gt;&gt;&gt; fh = open(&#8216;exec.sh&#8217;,&#8217;w&#8217;) &gt;&gt;&gt; fh.write(&#8216;#!\/bin\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.dogrow.net\/python\/blog39\/\">\u7d9a\u304d\u3092\u8aad\u3080 &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":[8],"tags":[],"class_list":["post-144","post","type-post","status-publish","format-standard","hentry","category-8"],"views":4052,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/144","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/comments?post=144"}],"version-history":[{"count":9,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/144\/revisions"}],"predecessor-version":[{"id":2637,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/144\/revisions\/2637"}],"wp:attachment":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/media?parent=144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/categories?post=144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/tags?post=144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}