{"id":568,"date":"2006-07-12T17:11:02","date_gmt":"2006-07-12T21:11:02","guid":{"rendered":"http:\/\/www.uvm.edu\/~waw\/blog\/?p=568"},"modified":"2006-07-12T17:11:02","modified_gmt":"2006-07-12T21:11:02","slug":"script-help","status":"publish","type":"post","link":"https:\/\/blog.uvm.edu\/waw\/2006\/07\/12\/script-help\/","title":{"rendered":"Script help"},"content":{"rendered":"<p>client asked <\/p>\n<div style=\"margin-left: 40px\"><span style=\"font-weight: bold;font-style: italic\">Hey all&#8230; I need to run a shell script on Zoo via PHP, and was<\/span><br style=\"font-weight: bold;font-style: italic\" \/><span style=\"font-weight: bold;font-style: italic\"> trying to use the PHP exec() function.<\/span><br style=\"font-weight: bold;font-style: italic\" \/><br style=\"font-weight: bold;font-style: italic\" \/><span style=\"font-weight: bold;font-style: italic\"> The script will manipulate some images using ImageMagick. Everything<\/span><br style=\"font-weight: bold;font-style: italic\" \/><span style=\"font-weight: bold;font-style: italic\"> works fine when calling the script from the command-line. I&#8217;m having<\/span><br style=\"font-weight: bold;font-style: italic\" \/><span style=\"font-weight: bold;font-style: italic\"> trouble, however, running it via PHP<\/span><br style=\"font-weight: bold;font-style: italic\" \/><br style=\"font-weight: bold;font-style: italic\" \/><span style=\"font-weight: bold;font-style: italic\"> The .sh file is owend by the account that the PHP file resides under.<\/span><br style=\"font-weight: bold;font-style: italic\" \/><br style=\"font-weight: bold;font-style: italic\" \/><span style=\"font-weight: bold;font-style: italic\"> What should the path to the shell script be (relative vs. absolute),<\/span><br style=\"font-weight: bold;font-style: italic\" \/><span style=\"font-weight: bold;font-style: italic\"> and will I encounter any issues trying to use exec() once my path is<\/span><br style=\"font-weight: bold;font-style: italic\" \/><span style=\"font-weight: bold;font-style: italic\"> correct?<\/span><\/div>\n<p>Best to use absolute path, so there is no ambiguity<\/p>\n<p>Best to use alias of your script&#8217;s folder. In general, any users alias is formed using the convention<\/p>\n<p>&nbsp;&nbsp;&nbsp; \/users\/x\/y\/xyzzzzz<\/p>\n<p>where x is the first letter of the use&#8217;rs NetID, y is the second letter of the user&#8217;s NetID, and xyzzzzz is the user&#8217;s netid.<\/p>\n<p>here&#8217;s an example. No issues for me running this in my home directory<\/p>\n<p>#!\/usr\/local\/bin\/php<br \/>&lt;?<br \/>passthru(&quot;\/users\/w\/a\/waw\/mysqltest.pl&quot;);<br \/>$dog=exec(&quot;\/usr\/bin\/date&quot;);<br \/>print &quot;dog=$dog&quot;;<br \/>?&gt;<\/p>\n<p>except he meant to run it via http:\/\/www.uvm.edu\/<\/p>\n<p>I sugegsted he try cgi.uvm.edu &#8212; no SAFE mode there<\/p>\n","protected":false},"excerpt":{"rendered":"<p>client asked Hey all&#8230; I need to run a shell script on Zoo via PHP, and was trying to use the PHP exec() function. The script will manipulate some images using ImageMagick. Everything works fine when calling the script from &hellip; <a href=\"https:\/\/blog.uvm.edu\/waw\/2006\/07\/12\/script-help\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6517,8025],"tags":[],"class_list":["post-568","post","type-post","status-publish","format-standard","hentry","category-projects","category-scriptingprogramming"],"_links":{"self":[{"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/posts\/568","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/comments?post=568"}],"version-history":[{"count":0,"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/posts\/568\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/media?parent=568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/categories?post=568"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/tags?post=568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}