If the web server (Apache) is running as 'webuser' and you can log on as webuser and run top, then your CGI code should be able to also.
So, the problem appears tp be elswhere..... not sure where, though. How about we try a very simple piece of code to make sure nothing else is tripping us up here. Try copy/paste/save this into a file, dos2unix it, chmod +x, and hit it from a browser.
Code:
#!/usr/local/bin/perl
$it = (system("top -n 10 > top.txt"))/256;
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>Top system Test</TITLE></HEAD>
<BODY><P>Ran top. Exit status: $it</P></BODY></HTML>";
That is about as simple as it gets. You should get an exit status of '1' back if the system call works.
See if that works. If it does, then we need to look at your original piece of code and see what may be corrupting the situation. If it does not, we'll look closer at the simple case.
On another issue.... do you mean to be catching the output of the 'top' command? If so, 'system' is not the way to do that trick. All 'system' will return is an exit status of the command that was called. You would need to use back ticks or a pipe to catch the output of 'top'.
HTH
If you are new to Tek-Tips, please use descriptive titles, check the FAQs,
and beware the evil typo.