Zmodem transfers in a telnet session

Zmodem transfers in a telnet session

Post by Bradley W. Owe » Tue, 16 Sep 1997 04:00:00



Is there a way to do a zmodem file transfer while in a telnet session in
a rxvt terminal?

--
-------------------------------------------------------------------------
Brad Owen                    The aim of epistemology is the

                             justification of cognitions.
                                                       Rudolf Carnap
-------------------------------------------------------------------------

 
 
 

Zmodem transfers in a telnet session

Post by Uwe Oh » Thu, 18 Sep 1997 04:00:00


Hello Bradley,

>Is there a way to do a zmodem file transfer while in a telnet session in
>a rxvt terminal?

not until you patch your telnet client to allow starting of external
programs with stdin/out connected to the remote side.

The appended patch might or might not help you. It defines a new command
"|" (like !, but with stdin/out connected to remote).

Regards, Uwe

diff -ur ./commands.c /usr/src/redhat/SOURCES/NetKit-B-0.06/telnet/commands.c
--- ./commands.c        Mon May 23 11:11:50 1994
+++ /usr/src/redhat/SOURCES/NetKit-B-0.06/telnet/commands.c     Mon May 27 14:32:22 1996
@@ -57,6 +57,7 @@
 #include <pwd.h>
 #include <varargs.h>
 #include <errno.h>
+#include <sys/time.h>

 #include <arpa/inet.h>
 #include <arpa/telnet.h>
@@ -70,10 +71,12 @@
 #include "types.h"

 #ifndef CRAY
+#include <netinet/in_systm.h>
 # if (defined(vax) || defined(tahoe) || defined(hp300)) && !defined(ultrix)
 # include <machine/endian.h>
 # endif /* vax */
 #endif /* CRAY */
+#include <netinet/ip.h>

 #ifndef       MAXHOSTNAMELEN
@@ -115,9 +118,12 @@

     margc = 0;
     cp = line;
-    if (*cp == '!') {          /* Special case shell escape */
+    if (*cp == '!' || *cp=='|') {              /* Special case shell escape */
        strcpy(saveline, line); /* save for shell command */
-       *argp++ = "!";                /* No room in string to get this */
+       if (*cp=='!')
+               *argp++ = "!";                /* No room in string to get this */
+       else
+               *argp++ = "|";                /* No room in string to get this */
        margc++;
        cp++;
     }
@@ -1407,6 +1413,133 @@
 }
 #endif /* !defined(TN3270) */

+#if    !defined(TN3270)
+dopipe(argc, argv)
+    int argc;
+    char *argv[];
+{
+       int p_in[2];
+       int p_out[2];
+    setcommandmode();
+    if (pipe(p_in)) {
+               perror("Pipe failed\n");
+               return 1;
+    }
+    if (pipe(p_out)) {
+               perror("Pipe failed\n");
+       close(p_in[0]);
+       close(p_out[1]);
+               return 1;
+    }
+    switch(vfork()) {
+    case -1:
+       perror("Fork failed\n");
+       break;
+
+    case 0:
+       {
+           /*
+            * Fire up the shell in the child.
+            */
+           register char *shellp, *shellname;
+           extern char *rindex();
+           close(p_in[1]);
+           close(p_out[0]);
+           if (dup2(p_in[0],0) || dup2(p_out[1],1)!=1)
+           {
+                       perror("Execl");
+                       _exit(1);
+           }
+           close(p_in[0]);
+           close(p_out[1]);
+
+           shellp = getenv("SHELL");
+           if (shellp == NULL)
+               shellp = "/bin/sh";
+           if ((shellname = rindex(shellp, '/')) == 0)
+               shellname = shellp;
+           else
+               shellname++;
+           if (argc > 1)
+               execl(shellp, shellname, "-c", &saveline[1], 0);
+           else
+               execl(shellp, shellname, 0);
+           perror("Execl");
+           _exit(1);
+       }
+    default:
+           close(p_in[0]);
+           close(p_out[1]);
+           {
+               fd_set iset;
+               while (1)
+               {
+                       char c;
+                       FD_ZERO(&iset);
+                               FD_SET(p_out[0],&iset);
+                               FD_SET(net,&iset);
+                       c=select(16, &iset, 0,0,0);
+                       if (c==-1 && errno ==EINTR)
+                               continue;
+                       if (c==-1)
+                       {
+                               perror("Select failed");
+                               break;
+                       }
+                       if (FD_ISSET(net,&iset))
+                       {
+                               unsigned char buf[8192];
+                               int count;
+                               count=read(net,buf,sizeof(buf));
+                               if (count > 0)
+                               {
+                                       unsigned char *p,*q;
+                                       for (p=q=buf;p-buf<count;p++)
+                                       {
+                                               if (*p!=IAC)
+                                                       *q++=*p;
+                                               else
+                                                       *q++=*p++;
+                                       }
+                                       write(p_in[1],buf,q-buf);
+                               }
+                       }
+                       if (FD_ISSET(p_out[0],&iset))
+                       {
+                               unsigned char buf[8192];
+                               unsigned char buf2[8192];
+                               int count;
+                               count=read(p_out[0],buf,sizeof(buf));
+                               if (count > 0)
+                               {
+                                       unsigned char *p,*q;
+                                       for (p=buf,q=buf2;p-buf<count;p++)
+                                       {
+                                               *q++=*p;
+                                               if (*p==IAC)
+                                                       *q++=*p;
+                                       }
+                                       write(net,buf2,q-buf2);
+                               }
+                               else if (count==0)
+                                       break; /* end of pipe */
+                               else if (errno!=EINTR)
+                               {
+                                       perror("Read failed");
+                                       break;
+                               }
+                       }
+
+               }
+           }
+           close(p_in[1]);
+           close(p_out[0]);
+           (void)wait((int *)0);       /* Wait for the shell to complete */
+    }
+    return 1;
+}
+#endif /* !defined(TN3270) */
+
     /*VARARGS*/
     static
 bye(argc, argv)
@@ -2389,6 +2522,7 @@
        zhelp[] =       "suspend telnet",
 #endif /* defined(unix) */
        shellhelp[] =   "invoke a subshell",
+       pipehelp[] =    "invoke a subshell, with stdin/out connected to remote host",
        envhelp[] =     "change environment variables ('environ ?' for more)",
        modestring[] = "try to enter line or character mode ('mode ?' for more)";

@@ -2419,8 +2553,11 @@
 #if    defined(unix)
        { "z",                zhelp,          suspend,        0 },
 #endif /* defined(unix) */
-#if    defined(TN3270)
+#if    !defined(TN3270)
        { "!",                shellhelp,      shell,          0 },
+#endif
+#if    !defined(TN3270)
+       { "|",                pipehelp,       dopipe,         0 },
 #endif
        { "environ",  envhelp,        env_cmd,        0 },
        { "?",                helphelp,       help,           0 },

 
 
 

Zmodem transfers in a telnet session

Post by Kent Robott » Sat, 20 Sep 1997 04:00:00



Quote:> Is there a way to do a zmodem file transfer while in a telnet session in
> a rxvt terminal?

Try ztelnet-1.0 at sunsite.
ftp://sunsite.unc.edu/pub/Linux/Incoming
ztelnet-1.0.tgz

Maybe later it will move to: /pub/Linux/system/network/?

 
 
 

Zmodem transfers in a telnet session

Post by bill davids » Tue, 23 Sep 1997 04:00:00




|
| Is there a way to do a zmodem file transfer while in a telnet session in
| a rxvt terminal?

If you are willing to define that as "using the telnet port" I
recommend the Kermit program. You make a telnet connection with
"host xx.yy.zz" and login, then run the sz command on the far end
and escape back to the command level and use the REDIR command to
run rz. You can use and program with Kermit REDIR, and it runs over
serial lines as well.

It's not on the CDs anymore, because Frank DaCruz decided he would
make more money selling his book if no one could distribute his
software any more... but it's still free on watsun.columbia.edu.
Actually, try kermit.columbia.edu, same machine the last time I
looked, but who knows?

Kermit is a fine program, but it's dying because no one can give it
away anymore.
--

Carolyn replied, "But I'm not that silly girl you roomed with for four
years anymore! I've cleaned up my act! I've given up hallucinogenic
*, and only have sex with vertebrate mammals."

 
 
 

Zmodem transfers in a telnet session

Post by Kent Robott » Fri, 26 Sep 1997 04:00:00





> |
> | Is there a way to do a zmodem file transfer while in a telnet session in
> | a rxvt terminal?

Try ztelnet it has builtin zmodem as well as a pipe | commaind, so
you can use an externel protocol zmodem, kermit, etc.

ftp://sunsite.unc.edu/pub/Linux/system/network/telnet
ztelnet-1.0.bin.ELF.tgz

 
 
 

1. zmodem through telnet session

I'm attempting to get zmodem to operate through a TCP/IP based telnet
session.  I can send a file from the RS/6000 with no problem, but
going the other way causes serious CRC errors and an eventual abort.

Anyone have any ideas on this one?

--

Marcus Mullins

LEXIS-NEXIS

/* If at first you don't succeed, skydiving isn't for you */

/*    All opinions expressed are my own      */

2. Linux on Suns

3. HELP! Using zmodem across a telnet session.

4. Casio QV-10 HOWTO

5. connection timeout ..why?

6. rz/zmodem: tip session, escape to local 'rz' for zmodem download

7. ftp dir command hangs

8. transferring telnet session

9. Any way to 'transfer' a telnet session?

10. Session disconnects in a telnet session

11. --> Session disconnects in a telnet session <--

12. Difference between XWindows session and telnet session