First, I'm not really sure what nmap is. That's probably not too important.
Second, I'm not sure what a root-only binary is doing in /usr/bin. It should be in /usr/sbin. So that's a bit odd.
Finally, you want sudo. It provides the ability to allow a user (e.g., "wwwrun" or "apache" or whatever your server drops privileges to) to become another user (e.g., 'root') to run specific programs (e.g., "/usr/bin/nmap"), optionally (well, mandatory for you) without providing a password.
my $output = `sudo /usr/bin/nmap -sU -p 2300,6500 $ENV{'REMOTE_ADDR'}` +;
Note that setting the suid bit is not enough unless the program is written to take advantage of the bit.
Update: Not sure what I'm on. I still prefer sudo to set-uid.
In reply to Re: Capturing the output of nmap from within a Perl script
by Tanktalus
in thread Capturing the output of nmap from within a Perl script
by spaceout
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |