DataSpy Posted March 21, 2012 Share Posted March 21, 2012 I'm using system() to run NMAP and then display the output but it's one big string, how can I format it to look like what I see in the command line? web app output: Starting Nmap 5.00 ( http://nmap.org ) at 2012-03-21 18:44 CDT Interesting ports on localhost (127.0.0.1): Not shown: 993 closed ports PORT STATE SERVICE 80/tcp open http 111/tcp open rpcbind 139/tcp open netbios-ssn 443/tcp open https 445/tcp open microsoft-ds 631/tcp open ipp 3306/tcp open mysql Nmap done: 1 IP address (1 host up) scanned in 0.11 seconds 0 command line output: Starting Nmap 5.00 ( http://nmap.org ) at 2012-03-21 18:48 CDT Interesting ports on localhost (127.0.0.1): Not shown: 993 closed ports PORT STATE SERVICE 80/tcp open http 111/tcp open rpcbind 139/tcp open netbios-ssn 443/tcp open https 445/tcp open microsoft-ds 631/tcp open ipp 3306/tcp open mysql Nmap done: 1 IP address (1 host up) scanned in 0.45 seconds <?php // path to NMAP $Path = '/usr/bin/nmap'; if(isset($_POST['scan'])) { $IP = $_POST['IP']; $ScanType = $_POST['ScanType']; echo "<br /><u>Results for NMAP Scan</u> <br />"; system("$Path $ScanType $IP 2>&1", $Output); echo $Output; } ?> any help would be greatly appreciated, thanks in advance!! Quote Link to comment https://forums.phpfreaks.com/topic/259460-help-formating-output/ Share on other sites More sharing options...
Mahngiel Posted March 22, 2012 Share Posted March 22, 2012 My PHP regex is shoddy at best, but in bash you would use grep, awk, and sed to cut the line up. This of course requires there to be some sort of static output. I've not played with nmap nor php regex, so I can't help you there, but hopefully at least you have some direction to pursue. Quote Link to comment https://forums.phpfreaks.com/topic/259460-help-formating-output/#findComment-1330048 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.