Can anyone help me understand zmodem and tcp? reddit / bbs ---------------------------------------------------------------------- rjcarr · 2022-04-04 08:26 I'm a programmer and I've been around a long time, but I'm a bit too young for really getting into bbs at the time (rather, I was around, just not into it then). I fundamentally understand how zmodem works, and how files can be sent (sz) and received (rz), but I think this was mostly for direct connections, e.g., via modem or serial link. What I'm trying to understand is how would I make zmodem transfer using a tcp socket connection? If I use some tool like TeraTerm or Putty I know I can log into the remote system, start `rz`, and then use the menus to select a file to initiate a transfer using zmodem. But what if I just have a raw socket connection and I've "logged in" using `/usr/bin/login`? I can't wrap my head around how I would tell the remote host to receive, while at the same time telling the local connection to send, all from the same terminal. Note I don't have access to windows and I'm using linux (ubuntu) or macOS (using lrzsz package from homebrew). Maybe there's a better sub to ask? I figured there'd be some zmodem experts on here. Thanks! ---------------------------------------------------------------------- Call_Me_Mauve_Bib · 2022-04-04 10:35 check out zssh. I don't know why you'd want to forgo ssh over the TCP layer at this point, but even if you do, it might be a good starting point. ---------------------------------------------------------------------- Zmodem · 2022-04-04 14:17 You might want to check out [SEXYZ](http://www.synchro.net/docs/sexyz.txt) and see if it is a good approach for a modern solution. [Help Docs](http://www.synchro.net/docs/index.htm). ---------------------------------------------------------------------- ILikeBumblebees · 2022-04-04 14:23 You wouldn't do it from the same terminal. You'd need to pipe the `sz` output into the socket on one end, then pipe the socket to `rz` on the other. So you need to escape out to the local system to do it. ---------------------------------------------------------------------- rjcarr · 2022-04-04 17:42 Thanks, yeah, I've seen that, but I specifically need it over a raw socket. ---------------------------------------------------------------------- rjcarr · 2022-04-04 17:42 I've heard of that but haven't really looked into it. I'll check it out, thanks! ---------------------------------------------------------------------- rjcarr · 2022-04-04 17:44 OK, thanks, this is what I figured, but just can't understand how to reattach to the open socket once I've escaped out of the process. ---------------------------------------------------------------------- denzuko · 2022-04-04 18:31 Here's the download. Zmodem was effective before tcp/ip. It's effectively OSI layer 4 for serial link communication. Yes, tcp streams can act as the transport encapsulation for x/y/z-modem transfers but ay the end of the day your just shoving bits down one pipeline to a receiver. Things to note in modern use. Windows, Mac, and tmux are borked beyond repair. One has to use screen and a xterm compliant terminal emulator or similar for it to work. Sexyz or Lrxsx is the goto package on posix systems but Kermit also still lives and works. Plus telix is floating out there. Another thing; Dont try over WiFi or voip. The physical links are way to unreliable but if you so get to work reliably; please publish the guide here or on 2600. But yes /u/ILikeBumbleBees is spot on with the rest. But do check out this tutorial on how to use screen with lrxsx: https://gist.github.com/Sulter/d2ce41ca2dc5f59738d80c728f6b669e ``` Sending from remote -> local * screen into remote * ctrl-a : zmodem catch * 'sz filename' on the remote (in terminal) Sending from local -> remote * screen into remote * ctrl-a : zmodem catch * 'rz' on the remote (in terminal) (add -y to overwrite existing files) * screen will ask for filename - enter filename and press ENTER ``` ---------------------------------------------------------------------- denzuko · 2022-04-04 18:32 Meh.. Screen, uucp, or kermit with sexyz works just as well. ---------------------------------------------------------------------- denzuko · 2022-04-04 18:46 Also going to add, I've had success with uucp over ssh and zmodem transfers. Typically how I use cu(1) to download allfiles.txt or with some expect(1) scripting make \`FREQs from other boards. ---------------------------------------------------------------------- rjcarr · 2022-04-04 19:31 Yeah, I should have mentioned I know there are modern alternatives, but for my use case I need to get zmodem working. Thanks for all the information, particularly about `screen`, as I hadn't considered that. ---------------------------------------------------------------------- rjcarr · 2022-04-04 21:02 I'm trying to follow the guide and unfortunately not following. I wasn't familiar with screen but have learned the basics since, but still, not understanding the procedure. For example, what is "screen into remote"? Does this mean ssh or some other connection? Then what is a "zmodem catch"? Again, just not following. If you have the time, could you break down what I'm supposed to do in more detail? Assume I have two computers, both with ssh (if necessary) and lrzsz and screen packages, and I want to transfer a file between them (the direction isn't important). Thanks! ---------------------------------------------------------------------- Souporsoaker · 2022-04-04 21:37 ncat? ---------------------------------------------------------------------- denzuko · 2022-04-04 22:19 by 'screen into remote' that means by what ever means needed to initiate a remote session and stream. So for example (going to use ssh but also `cu(1)` from uucp, netcat/socat, rexec or telnet works too: 1. `cat ->> $HOME/.screenrc <<< "zmodem catch"` 2. `screen ssh fileserv sz /var/spool/uucp/public/allfiles.txt` 3. *hit* `control+a`. Screen will interpret the zmodem escape codes for initializing a transfer then fork(3) to rz ---------------------------------------------------------------------- rjcarr · 2022-04-04 22:34 Thanks for the response; I'm still not understanding, but I'll try to figure out what you've written eventually. Cheers! ---------------------------------------------------------------------- Call_Me_Mauve_Bib · 2022-04-05 01:15 if you like screen, you'll love `tmux` ---------------------------------------------------------------------- rjcarr · 2022-04-05 01:43 Thanks so much for helping me, and if you can just bear with me a bit more, I think I can get this. Here's what I have: * one ubuntu system with two users: user1 and user2 * they can ssh to each other with keys, e.g.: `user1:~$> ssh user2@localhost` * lrzsz and screen are installed * have a simple text file `send.txt` in home of user1. Here's what I've done from your guidance, from user1: 1. I appended `zmodem catch` to `.screenrc` file in home directory. 2. Ran: `user1:~$> screen ssh user2@localhost sz send.txt` A blank screen appears that just says `rz` at the top and `:!!! rz -vv -b -E` in a screen prompt at the bottom. I press ctrl-a once and nothing happens. I press it again and it says: "No other window." After a few seconds, the terminal prompt returns and says "[screen is terminating]". Notes: * I used `sz` instead of the `sb` you recommended because otherwise it would just immediately terminate. * A file named 'send.txt.0' gets written on the *sender* side, but nothing on the receiver. Suggestions? Thanks again! ---------------------------------------------------------------------- denzuko · 2022-04-05 01:58 Don't mean this to sound pedantic, figured you grok it by now. Just posting the ELI5 version for google (because in all likelihood I'm going to run into someone else in the next five years or so that's going to need this.. mostly likely myself ;) ): * Step one, reconfigures screen(1) to parse stdin looking for zmodem escape/control codes. * Step two, starts the screen terminal multiplexer (a text ui "window" and session manager) with an tcp/ip+ssh connection to \`\`\`\`\`host 'fileserv' where on fileserv it executes sz(1) via the default shell and requests the absolute path to allfiles.txt in uucp public spool folder. * Step three, sz(1) should sit there waiting for confirmation of transfer where screen(1) interprets \`\^a\` to fork rz(1) and pass stdout to rz(1) in the background. ---------------------------------------------------------------------- Call_Me_Mauve_Bib · 2022-04-05 02:24 How adventurous do you want to get, do you want to mux the transfers with the terminal, or suspend terminal during transfer? ---------------------------------------------------------------------- Call_Me_Mauve_Bib · 2022-04-05 02:27 I guess you pipe it /through/ until the child is done, then you stop piping it through and just do terminal stuff with the bytestream. ---------------------------------------------------------------------- nhaines · 2022-04-05 02:30 > they can ssh to each other with keys Then please think very long and hard about why you shouldn't be using `scp`. There are reason, and that's fine. Right tool for the job and all that. Just make sure they're *your* reasons. ---------------------------------------------------------------------- denzuko · 2022-04-05 02:38 Yes your right there. But whom these days are going to set up a pppd, rlogin, uucp, or telnet server? Defacto remote command for Linux is ssh these days. Thus if one is experimenting with bad tech it's either with retro machines or over ssh. Plus zmodem works over Lora and ax25 with less overhead than So. So its fun stuff to play with. ---------------------------------------------------------------------- nhaines · 2022-04-05 02:42 Yeah, but right now he's using a single host and doing inter-user transfers. So either he's doing everything wrong, or he's (rightfully) starting simple and building up. But if he's expecting to use two Ubuntu hosts (or Linux or Unix or Unix-like or Windows 10/11 with SSH or with WSL and SSH), well... SSH already has a thing for file transfers. And SSHv2 even runs on DOS. So it's fine that OP's being really vague, but that's going to make it a lot harder to answer the question in a helpful manner. ---------------------------------------------------------------------- denzuko · 2022-04-05 02:43 Honestly the manpage is going to be a better read than reddit. But also experiment. Try rx on the sender side. Screen is smart enough to know which command to call with control a. Control a twice is screen's version of swap windows, control a c cording creates a new virtual window that takes control and control a twice hotseaps back. Also thinking the "blank screen" is just lrxsx waiting for input. ---------------------------------------------------------------------- rjcarr · 2022-04-05 03:25 I just need to test something. It has nothing to do with the “right tool”. ---------------------------------------------------------------------- nhaines · 2022-04-05 03:40 Then use the "wrong tool." I'm not invested in the steps it takes to get there. I'm just saying that the problem is vague and your test setup sounds very different than what you'd typically use ZModem for, and that makes it difficult to speculate on solutions other than generalities. ---------------------------------------------------------------------- rjcarr · 2022-04-05 07:31 OK, thanks for all the help, I really appreciate it. ---------------------------------------------------------------------- rjcarr · 2022-04-05 07:44 FYI: I found this link using your `zmodem catch` guidance and got it to work. I think it's 99% of what you described, but just explained a bit differently for me to try. Thanks again, I think I can make this work! https://gangmax.me/blog/2016/12/08/using-rz-slash-sz-to-transfer- files/ ---------------------------------------------------------------------- denzuko · 2022-04-06 03:57 Yeah the only difference is one is manually setting options with \^a :zmodem catch and breaking the step 2 from my earlier post into its components to run one at a time. (e.g. start screen. ssh over to fileserv. execute sz filename.) But I'm sure [gangmax.me](https://gangmax.me) is the source for this knowledge anyways. Just glad to hear you got it to work. Curious though, what are you going to do with it? (other than learn how to use xmodem over ssh) ---------------------------------------------------------------------- rjcarr · 2022-04-06 04:23 Yeah, now that I know what I'm doing, I can make it work with your method. I just needed it explained in a slightly different way and/or needed some time for it to digest. I'm working with autonomous vehicles that transfer data using zmodem, and I set up a server to receive the data, but didn't have a good way to test that the services were working outside of using the vehicle, which I don't want to do. Anyway, thanks again, cheers! ---------------------------------------------------------------------- denzuko · 2022-04-06 04:24 Sounds like fun! hey if you ever blog about how your doing it feel free to share here or in my DMs I'd love to hear more.