<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: system command not working within CGI script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860651#M53326</link>
    <description>Ouch !&lt;BR /&gt;&lt;BR /&gt;Patrick was right. I added mv to /usr/bin/mv. Should have been /bin/mv&lt;BR /&gt;&lt;BR /&gt;This now works&lt;BR /&gt;&lt;BR /&gt;Will look at the perl script for the configUpload with the information supplied&lt;BR /&gt;&lt;BR /&gt;TIA&lt;BR /&gt;&lt;BR /&gt;Steve</description>
    <pubDate>Mon, 11 Sep 2006 14:59:17 GMT</pubDate>
    <dc:creator>steven Burgess_2</dc:creator>
    <dc:date>2006-09-11T14:59:17Z</dc:date>
    <item>
      <title>system command not working within CGI script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860642#M53317</link>
      <description>Hi all&lt;BR /&gt;&lt;BR /&gt;I am trying to execute the following sub routine&lt;BR /&gt;&lt;BR /&gt;sub reset_config&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;my $dbh = shift;&lt;BR /&gt;my $sth;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;system("mv /tftpboot/processed/* /tftpboot");&lt;BR /&gt;&lt;BR /&gt;if ($? == -1) {&lt;BR /&gt;        print "failed to execute: $!\n";&lt;BR /&gt;}&lt;BR /&gt;elsif ($? &amp;amp; 127) {&lt;BR /&gt;        printf "child died with signal %d, %s coredump\n",&lt;BR /&gt;        ($? &amp;amp; 127),  ($? &amp;amp; 128) ? 'with' : 'without';&lt;BR /&gt;}&lt;BR /&gt;else {&lt;BR /&gt;        printf "child exited with value %d\n", $? &amp;gt;&amp;gt; 8;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;        $sth = $dbh-&amp;gt;prepare ("delete from tblConfig");&lt;BR /&gt;        $count = 0;&lt;BR /&gt;        $count += $sth-&amp;gt;execute ();&lt;BR /&gt;        $sth-&amp;gt;finish ();&lt;BR /&gt;&lt;BR /&gt;        print p ("Removed all configuration from tblConfig");&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This is called via a CGI script. For some reason I am getting a return value of 1 for the mv command, yet the delete from tblConfig works ok. If I run the code from the shell, it works.&lt;BR /&gt;&lt;BR /&gt;Any ideas ? Have checked file permissions and all appears to be ok&lt;BR /&gt;&lt;BR /&gt;TIA&lt;BR /&gt;&lt;BR /&gt;Steve&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 11 Sep 2006 13:21:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860642#M53317</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2006-09-11T13:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: system command not working within CGI script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860643#M53318</link>
      <description>Perhaps mv isn't in the path when the cgi script runs.  Does it make any difference if you fully qualify the path to mv (/usr/bin/mv)?</description>
      <pubDate>Mon, 11 Sep 2006 13:25:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860643#M53318</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2006-09-11T13:25:35Z</dc:date>
    </item>
    <item>
      <title>Re: system command not working within CGI script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860644#M53319</link>
      <description>Hi Patrick&lt;BR /&gt;&lt;BR /&gt;The return code changes to a 127, as opposed to a 1.&lt;BR /&gt;&lt;BR /&gt;Hmmm&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Mon, 11 Sep 2006 13:28:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860644#M53319</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2006-09-11T13:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: system command not working within CGI script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860645#M53320</link>
      <description>Errno 1 = EPERM which suggest that the effective UID does not have permission to write in the /tftpboot/processed directory and/or the /tfpboot directory.&lt;BR /&gt;&lt;BR /&gt;I would also change:&lt;BR /&gt;system("mv /tftpboot/processed/* /tftpboot");&lt;BR /&gt;&lt;BR /&gt;to&lt;BR /&gt;&lt;BR /&gt;$status = system("mv /tftpboot/processed/* /tftpboot");&lt;BR /&gt;&lt;BR /&gt;so that there is a more direct connection to the actual exit status of the system function.</description>
      <pubDate>Mon, 11 Sep 2006 13:33:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860645#M53320</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-09-11T13:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: system command not working within CGI script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860646#M53321</link>
      <description>Within the same script, I have another function&lt;BR /&gt;&lt;BR /&gt;sub upload_files&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;print p ("In upload files");&lt;BR /&gt;&lt;BR /&gt;system("/usr/red2/scripts/configUpload.pl");&lt;BR /&gt;&lt;BR /&gt;if ($? == -1) {&lt;BR /&gt;        print "failed to execute: $!\n";&lt;BR /&gt;}&lt;BR /&gt;elsif ($? &amp;amp; 127) {&lt;BR /&gt;        printf "child died with signal %d, %s coredump\n",&lt;BR /&gt;        ($? &amp;amp; 127),  ($? &amp;amp; 128) ? 'with' : 'without';&lt;BR /&gt;}&lt;BR /&gt;else {&lt;BR /&gt;        printf "child exited with value %d\n", $? &amp;gt;&amp;gt; 8;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;This returns with a 13, again, when I manually run the script all is ok.&lt;BR /&gt;&lt;BR /&gt;Just going to leave the office,go home and pick this up when I get in. &lt;BR /&gt;&lt;BR /&gt;It's for my masters assignment which should have been handed in today !!&lt;BR /&gt;&lt;BR /&gt;grateful for all input&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Mon, 11 Sep 2006 13:33:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860646#M53321</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2006-09-11T13:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: system command not working within CGI script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860647#M53322</link>
      <description>I have changed the permissions, for the period of this exercise to the following&lt;BR /&gt;&lt;BR /&gt;test-suse:/tftpboot # ls -ld processed/&lt;BR /&gt;drwxrwxrwx    2 root     root           48 Sep 11 19:30 processed/&lt;BR /&gt;test-suse:/tftpboot # ls -ld /tftpboot/&lt;BR /&gt;drwxrwxrwx    4 root     root          680 Sep 11 19:30 /tftpboot/&lt;BR /&gt;test-suse:/tftpboot # pwd&lt;BR /&gt;/tftpboot&lt;BR /&gt;&lt;BR /&gt;All the files have 666 perms&lt;BR /&gt;&lt;BR /&gt;Steve&lt;BR /&gt;</description>
      <pubDate>Mon, 11 Sep 2006 13:37:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860647#M53322</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2006-09-11T13:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: system command not working within CGI script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860648#M53323</link>
      <description>Have changed to &lt;BR /&gt;&lt;BR /&gt;my $status = system("/usr/bin/mv /tftpboot/processed/* /tftpboot/");&lt;BR /&gt;&lt;BR /&gt;Still get the same exit code&lt;BR /&gt;&lt;BR /&gt;Back shortly&lt;BR /&gt;&lt;BR /&gt;Thanks again&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Mon, 11 Sep 2006 13:42:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860648#M53323</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2006-09-11T13:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: system command not working within CGI script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860649#M53324</link>
      <description>Add a probe very similar to this so that the exit status, user information, and PATH is displayed.&lt;BR /&gt;$status = system("xxx yyy");&lt;BR /&gt;print "Status = ",$status,"\n";&lt;BR /&gt;($a,$b,$c) = (getpwuid($&amp;lt;)) [0,2,3]; &lt;BR /&gt;print "User: ",$a," UID ",$b," GID ",$c," EUID ",$&amp;lt;,"\n";&lt;BR /&gt;print "PATH: ",$ENV{PATH},"\n";&lt;BR /&gt;</description>
      <pubDate>Mon, 11 Sep 2006 13:56:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860649#M53324</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-09-11T13:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: system command not working within CGI script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860650#M53325</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;We have&lt;BR /&gt;&lt;BR /&gt;my $status = system("/usr/bin/mv /tftpboot/processed/* /tftpboot/");&lt;BR /&gt;&lt;BR /&gt;print "Status = ",$status,"\n";&lt;BR /&gt;my ($a,$b,$c) = (getpwuid($&amp;lt;)) [0,2,3];&lt;BR /&gt;&lt;BR /&gt;print "User: ",$a," UID ",$b," GID ",$c," EUID ",$&amp;lt;,"\n";&lt;BR /&gt;&lt;BR /&gt;print "PATH: ",$ENV{PATH},"\n";&lt;BR /&gt;&lt;BR /&gt;This displays&lt;BR /&gt;&lt;BR /&gt;Status = 32512 User: daemon UID 2 GID 2 EUID 2 PATH: /usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin &lt;BR /&gt;&lt;BR /&gt;I can move the files as the user daemon&lt;BR /&gt;&lt;BR /&gt;TIA&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Mon, 11 Sep 2006 14:54:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860650#M53325</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2006-09-11T14:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: system command not working within CGI script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860651#M53326</link>
      <description>Ouch !&lt;BR /&gt;&lt;BR /&gt;Patrick was right. I added mv to /usr/bin/mv. Should have been /bin/mv&lt;BR /&gt;&lt;BR /&gt;This now works&lt;BR /&gt;&lt;BR /&gt;Will look at the perl script for the configUpload with the information supplied&lt;BR /&gt;&lt;BR /&gt;TIA&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Mon, 11 Sep 2006 14:59:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860651#M53326</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2006-09-11T14:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: system command not working within CGI script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860652#M53327</link>
      <description>configUpload command fails because it couldn't write to an output file in /tmp&lt;BR /&gt;&lt;BR /&gt;The error output from the scripts is also in the apache error logs&lt;BR /&gt;&lt;BR /&gt;marvellous, marvellous, marvellous&lt;BR /&gt;&lt;BR /&gt;Thanks very much Patrick and Clay&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Mon, 11 Sep 2006 15:05:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860652#M53327</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2006-09-11T15:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: system command not working within CGI script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860653#M53328</link>
      <description>Hi Steve:&lt;BR /&gt;&lt;BR /&gt;The path '/bin' is a deprecated transition link to '/usr/bin'.  You should be using '/usr/bin' and not '/bin'.&lt;BR /&gt;&lt;BR /&gt;That aside, your checks for the return code are correct and are directly from the Perl documentation, so there is nothing wrong with the way you check the success or lack thereof of the system() call.&lt;BR /&gt;&lt;BR /&gt;You might get a return code of &amp;lt;1&amp;gt; from 'mv' if there wasn't a source, for example.&lt;BR /&gt;&lt;BR /&gt;You could avoid invoking the shell with your 'system()' call by passing multiple arguments, like:&lt;BR /&gt;&lt;BR /&gt;# system("mv", (glob "/tftpboot/processed/*", "/tftpboot");&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 11 Sep 2006 15:14:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860653#M53328</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-09-11T15:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: system command not working within CGI script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860654#M53329</link>
      <description>Hi (again) Steve:&lt;BR /&gt;Sorry, a typo.  That should be:&lt;BR /&gt;&lt;BR /&gt;# system("mv", (glob "/tftpboot/processed/*"), "/tftpboot");&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 11 Sep 2006 15:15:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860654#M53329</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-09-11T15:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: system command not working within CGI script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860655#M53330</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;This is an "OLD" development server running suse 8.2, hence location of /bin&lt;BR /&gt;&lt;BR /&gt;Thanks again&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Mon, 11 Sep 2006 16:28:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860655#M53330</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2006-09-11T16:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: system command not working within CGI script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860656#M53331</link>
      <description>Well, since you neglected to mention the OS initially, I assumed you were talking about HP-UX since this was posted in an HP-UX forum.</description>
      <pubDate>Mon, 11 Sep 2006 16:34:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860656#M53331</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2006-09-11T16:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: system command not working within CGI script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860657#M53332</link>
      <description>Shalom Steve,&lt;BR /&gt;&lt;BR /&gt;Hey a Linux issue.&lt;BR /&gt;&lt;BR /&gt;CGI scripts are normally run from a web browser. For security reasons all scripts run from an httpd session have little or no permissions and ability to do anything.&lt;BR /&gt;&lt;BR /&gt;It has also been a standard practice for some years to chroot httpd servers to prevent exploits from having any power should they manage to chain a shell.&lt;BR /&gt;&lt;BR /&gt;This approach works from the shell because it is supposed to.&lt;BR /&gt;&lt;BR /&gt;if the server is not chrooted and you have sudo installed, and you have the environment set correctly this should work. But the above conditions make this a tough way to administer a system.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Mon, 11 Sep 2006 19:59:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/system-command-not-working-within-cgi-script/m-p/3860657#M53332</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2006-09-11T19:59:08Z</dc:date>
    </item>
  </channel>
</rss>

