Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to run nmap from a Bash script, in a way so that when Enter is pressed it should give some output, as happens when running directly from the commandline.

When calling a few different nmap scans from a Bash script, pressing Enter will not show the time remaining as it would if I ran it directly from the command line.

An example line from my script:

nmap -T4 -iL input.txt -PN -sS -oA tcp_top_1000

Running nmap like this via the command line, and then hitting Enter results in this type of output:

$ nmap -T4 -iL input.txt -PN -sS -oA tcp_top_1000

Starting Nmap 5.21 ( http://nmap.org ) at 2013-10-18 01:21 EDT
Stats: 0:00:01 elapsed; 0 hosts completed (0 up), 1 undergoing ARP Ping Scan
Parallel DNS resolution of 1 host. Timing: About 0.00% done
Stats: 0:00:01 elapsed; 0 hosts completed (0 up), 1 undergoing ARP Ping Scan
Parallel DNS resolution of 1 host. Timing: About 0.00% done
Stats: 0:00:02 elapsed; 0 hosts completed (0 up), 1 undergoing ARP Ping Scan
Parallel DNS resolution of 1 host. Timing: About 0.00% done

However running that same nmap command in a shell script inhibits it's ability to do the above.

Is there any way to solve this?

share|improve this question
    
Try to specify -i option in she-bang. It may help you. –  rush Oct 17 '13 at 22:11
    
Please provide us with an example of what you're doing. –  slm Oct 17 '13 at 22:39
    
@slm, I did provide an example. Calling nmap to do a scan from a script. The scan type or parameters don't matter. –  Sonny Ordell Oct 17 '13 at 23:51
    
Yeah that's not enough, please provide a couple of lines from the script. –  slm Oct 18 '13 at 0:07
    
@slm are you familiar with nmap? Really, the command doesn't matter, even "nmap host" will return output when enter is pressed while it is running. Besides, the problem isn't specific to a particular program. "nmap -sU host" is a fine example of a line from the script.. –  Sonny Ordell Oct 18 '13 at 0:49

1 Answer 1

yourcommand >> logfile.log 2>&1 

Above command capture your output in logfile.log file, Also it show any error messages and normal messages in stdout.

share|improve this answer
    
The OP is looking for interactive output. –  jasonwryan Oct 18 '13 at 4:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.