{"id":3238,"date":"2019-09-12T13:22:35","date_gmt":"2019-09-12T05:22:35","guid":{"rendered":"https:\/\/www.webteach.tw\/?p=3238"},"modified":"2019-09-12T13:22:35","modified_gmt":"2019-09-12T05:22:35","slug":"php-run-shell-script-error","status":"publish","type":"post","link":"https:\/\/www.webteach.tw\/?p=3238","title":{"rendered":"[ PHP ] &#8211; PHP run shell script error sudo: no tty present and no askpass program specified"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">shell_exec() \u53ef\u4ee5\u8b93php\u57f7\u884c\u5916\u90e8\u6307\u4ee4, \u4f46\u6703\u9047\u5230\u6b0a\u9650\u554f\u984c\u4ee5\u4e0b\u70ba\u89e3\u6cd5\u3002<br \/> \u9019\u908a\u8981\u5099\u8a3b\u4e00\u4e0b\uff0c\u5982\u679c\u4f60\u7684 shell script \u5728command line\u4e0b\u662f\u53ef\u6b63\u5e38\u57f7\u884c\uff0c\u900f\u904e shell_exec()\u4f86\u57f7\u884c\u537b\u4e0d\u4f5c\u52d5\u767e\u5206\u4e4b\u4e5d\u5341\u662f\u9019\u500b\u554f\u984c\uff1b<br \/> \u7576\u521d\u8981\u67e5\u7684\u6642\u5019\u4e00\u76f4\u63a5\u5230 null\u9019\u500b\u503c\uff0c\u4f60\u53ef\u4ee5\u88e1\u9762\u6307\u4ee4\u4e0d\u8b8a \u4f46\u6539\u7528exec()\u53bb\u57f7\u884c\u5c31\u53ef\u4ee5\u63a5\u5230\u7cfb\u7d71\u56de\u50b3\u7684\u932f\u8aa4\u78bc\u3002<\/p>\n\n\n<p class=\"wp-block-paragraph\">\u6307\u4ee4\uff1asudo visudo <\/p>\n\n\n<p class=\"wp-block-paragraph\">\u5728\u4e0b\u65b9\u52a0\u5165<br \/>\napache  ALL=(ALL) NOPASSWD: \/bin\/sh \/home\/jeff\/test.sh<br \/>\nwww-data  ALL=(ALL) NOPASSWD: \/bin\/sh \/home\/jeff\/test.sh<\/p>\n\n\n<p class=\"wp-block-paragraph\">\u9019\u6a23\u5c31\u53ef\u4ee5\u6b63\u5e38\u57f7\u884cshell script<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\t\t\t\tshell_exec() \u53ef\u4ee5\u8b93php\u57f7\u884c\u5916\u90e8\u6307\u4ee4, \u4f46\u6703\u9047\u5230\u6b0a\u9650\u554f\u984c\u4ee5\u4e0b\u70ba\u89e3\u6cd5\u3002<br \/>\n\u9019\u908a\u8981\u5099\u8a3b\u4e00\u4e0b\uff0c\u5982\u679c\u4f60\u7684 shell script \u5728command line\u4e0b\u662f\u53ef\u6b63\u5e38\u57f7\u884c\uff0c\u900f\u904e shell_exec()\u4f86\u57f7\u884c\u537b\u4e0d\u4f5c\u52d5\u767e\u5206\u4e4b\u4e5d\u5341\u662f\u9019\u500b\u554f\u984c\uff1b<br \/>\n\u7576\u521d\u8981\u67e5\u7684\u6642\u5019\u4e00\u76f4\u63a5\u5230 null\u9019\u500b\u503c\uff0c\u4f60\u53ef\u4ee5\u88e1\u9762\u6307\u4ee4\u4e0d\u8b8a \u4f46\u6539\u7528exec()\u53bb\u57f7\u884c\u5c31\u53ef\u4ee5\u63a5\u5230\u7cfb\u7d71\u56de\u50b3\u7684\u932f\u8aa4\u78bc\u3002\t\t<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32,36],"tags":[241,448,511],"class_list":["post-3238","post","type-post","status-publish","format-standard","hentry","category-linux","category-php","tag-error","tag-php","tag-shell-script"],"_links":{"self":[{"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/posts\/3238","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3238"}],"version-history":[{"count":0,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/posts\/3238\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.webteach.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}