From 1cca9484db69971f652dfef48778da0dc56dad12 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 10 Jul 2006 19:45:20 +0000 Subject: Upgrade netcat a lot. Make -e able to take the rest of the command line as what to exec. Add -f mode and a brief explanation of how to use it to replace minicom. Add -l -l mode so you can turn any command into a server. And group all of netcat's command line options under two CONFIG entries, so if you disable both it doesn't use getopt at all. --- include/libbb.h | 1 + include/usage.h | 42 ++++++++++++++++++++++++++++++------------ 2 files changed, 31 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/libbb.h b/include/libbb.h index 6d6213901..af45511d4 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include diff --git a/include/usage.h b/include/usage.h index 3c1fb18e9..7c63e2f85 100644 --- a/include/usage.h +++ b/include/usage.h @@ -2105,23 +2105,41 @@ USE_FEATURE_MDEV_CONFIG( \ " or\n" \ "$ nameif -c /etc/my_mactab_file\n" \ -#ifdef CONFIG_NC_GAPING_SECURITY_HOLE -# define USAGE_NC_EXEC(a) a +#if ENABLE_NC_SERVER || ENABLE_NC_EXTRA +#define NC_BR1 "[" +#define NC_BR2 "]" #else -# define USAGE_NC_EXEC(a) +#define NC_BR1 +#define NC_BR2 #endif + #define nc_trivial_usage \ - "[OPTIONS] [IP] [port]" + "[" \ + NC_BR1 USE_NC_SERVER("-lp")USE_NC_EXTRA("iwf") NC_BR2 \ + " ["USE_NC_EXTRA("FILENAME|")"{IPADDR PORTNUM}]"USE_NC_EXTRA(" [-e COMMAND]") #define nc_full_usage \ - "Netcat opens a pipe to IP:port\n\n" \ - "Options:\n" \ - "\t-l\t\tlisten mode, for inbound connects\n" \ - "\t-p PORT\t\tlocal port number\n" \ - "\t-i SECS\t\tdelay interval for lines sent\n" \ - USAGE_NC_EXEC( \ - "\t-e PROG\t\tprogram to exec after connect (dangerous!)\n" \ + "Netcat opens a pipe, either to IP:port\n\n" \ + "Options:" \ + USE_NC_EXTRA( \ + "\n\t-e\t\texec rest of command line after connect\n" \ + "\t-i SECS\t\tdelay interval for lines sent\n" \ + "\t-w SECS\t\ttimeout for connect\n" \ + "\t-f filename\tuse file (ala /dev/ttyS0) instead of network" \ ) \ - "\t-w SECS\t\ttimeout for connects and final net reads" + USE_NC_SERVER( \ + "\n\t-l\t\tlisten mode, for inbound connects\n" \ + USE_NC_EXTRA("\t\t\t(use -l twice with -e for persistent server)\n") \ + "\t-p PORT\t\tlocal port number" \ + ) + + +#define nc_notes_usage "" \ + USE_NC_EXTRA( \ + "To use netcat as a terminal emulator on a serial port:\n\n" \ + "$ stty 115200 -F /dev/ttyS0\n" \ + "$ stty raw -echo -ctlecho && nc -f /dev/ttyS0\n" \ + ) "" + #define nc_example_usage \ "$ nc foobar.somedomain.com 25\n" \ "220 foobar ESMTP Exim 3.12 #1 Sat, 15 Apr 2000 00:03:02 -0600\n" \ -- cgit v1.2.3