[BusyBox] bug#1242: netcat '-i' option
Cristian Ionescu-Idbohrn
cristian.ionescu-idbohrn at axis.com
Sat Apr 20 14:16:03 UTC 2002
Package: busybox
Version: 0.61.pre+cvs+2002-04-20:21:01
Severity: wishlist
Would you please add the '-i' option to netcat. It seems to be
required in order to be able to talk to an smtp-server.
This script below (which I'd like to use to be informed when the
floppyfw firewall dhcp-assigned-ip-address changes) works with a full
blown netcat, but not with the busybox one:
,---- nc-mail ----
| #!/bin/sh -e
|
| SMTP_HOST_=<smtp-server name/ip>
| FROM_HOST_=<ffw-hostname>
| FROM_=<sender email-address>
| TO_=<receipient email-adress>
|
| FFWEXTIP_=`ifconfig eth0 | grep 'addr:' | cut -d\: -f2 | cut -d\ -f1`
| TIME_=`date +%Y-%m-%d:%T`
|
|
| echo "EHLO $FROM_HOST_
| MAIL From: $FROM_
| RCPT To: $TO_
| DATA
| From: $FROM_
| To: $TO_
| Subject: time: $TIME_, extip: $FFWEXTIP_
| .
| QUIT" | nc -i 1 $SMTP_HOST_ 25
|
| exit 0
`----
It looks like the mods required would be minimal. Here is a patch (not
tested yet):
--- networking/nc.c.original Wed May 16 17:40:48 2001
+++ networking/nc.c Sat Apr 20 21:49:33 2002
@@ -42,7 +42,7 @@
int nc_main(int argc, char **argv)
{
- int do_listen = 0, lport = 0, tmpfd, opt, sfd;
+ int do_listen = 0, delay = 0, lport = 0, tmpfd, opt, sfd;
char buf[BUFSIZ];
struct sockaddr_in address;
@@ -52,6 +52,9 @@ int nc_main(int argc, char **argv)
while ((opt = getopt(argc, argv, "lp:")) > 0) {
switch (opt) {
+ case 'i':
+ delay = atoi(optarg);
+ break;
case 'l':
do_listen++;
break;
@@ -131,6 +134,10 @@ int nc_main(int argc, char **argv)
if (full_write(ofd, buf, nread) < 0)
perror_msg_and_die("write");
+
+ if (delay > 0) {
+ sleep(delay);
+ }
}
}
}
Cheers,
Cristian
More information about the busybox
mailing list