发信人: jokhva()
整理人: hackerbay(2002-09-06 16:48:51), 站内信件
|
可以使telnet传输文件内容, 比如在字符模式下上BBS, 要把本地的文件内容
给贴过去, 但是无法在字符模式下剪贴, 就可以用这个功能.
方法: telnet>send file 要传输的文件名
------------------------begin of telnet.pacth-0.1 ------------
*** /usr/src/usr.bin/telnet/commands.c Mon May 28 03:44:48 2001
--- ./commands.c Sun Apr 14 22:54:35 2002
*************** static int
*** 291,297 ****
send_dontcmd P((char *)),
send_willcmd P((char *)),
send_wontcmd P((char *));
!
static struct sendlist Sendlist[] = {
{ "ao", "Send Telnet Abort output", 1, 0, 0, 2, AO },
{ "ayt", "Send Telnet 'Are You There'", 1, 0, 0, 2, AYT },
--- 291,297 ----
send_dontcmd P((char *)),
send_willcmd P((char *)),
send_wontcmd P((char *));
! void send_file P((char *));
static struct sendlist Sendlist[] = {
{ "ao", "Send Telnet Abort output", 1, 0, 0, 2, AO },
{ "ayt", "Send Telnet 'Are You There'", 1, 0, 0, 2, AYT },
*************** static struct sendlist Sendlist[] = {
*** 318,323 ****
--- 318,324 ----
{ "dont", 0, 0, 1, send_dontcmd, 3, 0 },
{ "will", 0, 0, 1, send_willcmd, 3, 0 },
{ "wont", 0, 0, 1, send_wontcmd, 3, 0 },
+ { "file", "Send file to remote host", 0, 1, send_file, 3, 0 },
{ 0 }
};
*************** send_wontcmd(name)
*** 439,444 ****
--- 440,465 ----
char *name;
{
return(send_tncmd(send_wont, "wont", name));
+ }
+
+ void
+ send_file(name)
+ char *name;
+ {
+ int fd;
+ char buf[10*BUFSIZ];
+
+ fd = open(name, O_RDONLY, 0);
+
+ if(fd)
+ while(read(fd, buf, 1) > 0)
+ write(net, buf, 1);
+ else {
+ printf("Error opening file!\n");
+ return ;
+ }
+ close(fd);
+ return ;
}
int
----------------------------end of telnet.patch-0.1 ----------
|
|