Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nc: invalid option -- 4 #65

Open
kehao95 opened this issue May 9, 2017 · 3 comments
Open

nc: invalid option -- 4 #65

kehao95 opened this issue May 9, 2017 · 3 comments

Comments

@kehao95
Copy link

kehao95 commented May 9, 2017

Hi, I couldn't run the nc command as expected.
It seems I have a different version of netcat.
I am using macOS Sierra 10.12.5

$ echo -n "black" | nc -4u -w0 localhost 1738

nc: invalid option -- 4
Try `nc --help' for more information.

$ nc --version

netcat (The GNU Netcat) 0.7.1
Copyright (C) 2002 - 2003  Giovanni Giacobbi

This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of this program under the terms of
the GNU General Public License.
For more information about these matters, see the file named COPYING.

Original idea and design by Avian Research <[email protected]>,
Written by Giovanni Giacobbi <[email protected]>.

$ nc --help

GNU netcat 0.7.1, a rewrite of the famous networking tool.
Basic usages:
connect to somewhere:  nc [options] hostname port [port] ...
listen for inbound:    nc -l -p port [options] [hostname] [port] ...
tunnel to somewhere:   nc -L hostname:port -p port [options]

Mandatory arguments to long options are mandatory for short options too.
Options:
  -c, --close                close connection on EOF from stdin
  -e, --exec=PROGRAM         program to exec after connect
  -g, --gateway=LIST         source-routing hop point[s], up to 8
  -G, --pointer=NUM          source-routing pointer: 4, 8, 12, ...
  -h, --help                 display this help and exit
  -i, --interval=SECS        delay interval for lines sent, ports scanned
  -l, --listen               listen mode, for inbound connects
  -L, --tunnel=ADDRESS:PORT  forward local port to remote address
  -n, --dont-resolve         numeric-only IP addresses, no DNS
  -o, --output=FILE          output hexdump traffic to FILE (implies -x)
  -p, --local-port=NUM       local port number
  -r, --randomize            randomize local and remote ports
  -s, --source=ADDRESS       local source address (ip or hostname)
  -t, --tcp                  TCP mode (default)
  -T, --telnet               answer using TELNET negotiation
  -u, --udp                  UDP mode
  -v, --verbose              verbose (use twice to be more verbose)
  -V, --version              output version information and exit
  -x, --hexdump              hexdump incoming and outgoing traffic
  -w, --wait=SECS            timeout for connects and final net reads
  -z, --zero                 zero-I/O mode (used for scanning)

Remote port number can also be specified as range.  Example: '1-1024'
@kehao95
Copy link
Author

kehao95 commented May 9, 2017

And this can be solved by using following command:

echo -n "green" | nc -u -c localhost 1738

@poige
Copy link

poige commented Jun 10, 2018

In fact there's no need for nc at all if one's using bash:

bash -c 'echo -n black > /dev/udp/localhost/1738'

@chaitanyarahalkar
Copy link

And this can be solved by using following command:

echo -n "green" | nc -u -c localhost 1738

Thanks a lot. I was facing the same issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants