why are you trying to redirect before the command as well as after?
Code:
[user@server ~]$ nmap -p22 google.com
Starting Nmap 5.51 ( http://nmap.org ) at 2013-06-17 16:36 EDT
Nmap scan report for google.com (74.125.140.101)
Host is up (0.036s latency).
Other addresses for google.com (not scanned): 74.125.140.102 74.125.140.113 74.125.140.139 74.125.140.100 74.125.140.138
rDNS record for 74.125.140.101: ye-in-f101.1e100.net
PORT STATE SERVICE
22/tcp filtered ssh
Nmap done: 1 IP address (1 host up) scanned in 0.56 seconds
[user@server ~]$ nmap -p22 google.com > foo.txt
[user@server ~]$ cat foo.txt
Starting Nmap 5.51 ( http://nmap.org ) at 2013-06-17 16:36 EDT
Nmap scan report for google.com (74.125.140.138)
Host is up (0.024s latency).
Other addresses for google.com (not scanned): 74.125.140.100 74.125.140.139 74.125.140.113 74.125.140.102 74.125.140.101
rDNS record for 74.125.140.138: ye-in-f138.1e100.net
PORT STATE SERVICE
22/tcp filtered ssh
Nmap done: 1 IP address (1 host up) scanned in 0.36 seconds
like that. your output indicates that you are trying to redirect the input into the output, that is not going to work.
also please use code flags. [ code ] [ / code ] remove the spaces and put your copy/paste from the CLI into them.
p.s. if you are putting this into a script, it might be a good idea to use >> instead of >
> will create the file and overwrite 100% of data inside the file.
>> will create the file if it does not exist and if it does it will "append" to the end of the file the new output.