# Receive ZModem

**URL:** <https://community.unix.com/t/receive-zmodem/386821>\
**Category:** Programming\
**Created:** [May 31, 2022, 9:57pm UTC](https://community.unix.com/t/receive-zmodem/386821 "2022-05-31T21:57:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ignatius](https://community.unix.com/letter_avatar/ignatius/32/5_5575768a8748004e209b776fc1b2916d.png) [@ignatius](https://community.unix.com/u/ignatius)\
**Post date:** [May 31, 2022, 9:57pm UTC](https://community.unix.com/t/receive-zmodem/386821/1 "2022-05-31T21:57:44Z")

</div>

Hello.

I'm trying to get rz (receive zmodem) working with my program... I have the following relevant code so far:

```nohighlight

        int zmodem_result=1;
        pid_t childpid;

                if ((childpid = fork()))
                { 
                        execlp("rz","rz",NULL); 
                        perror("exec() of rz failed"); 
                        exit(-1);
                }
                else if (childpid>0)
                        wait(&zmodem_result);
                else perror("fork failed");
                break;

```

When I initiate a download from the server, I get:

```nohighlight
fork failed: Success
è rz waiting to receive.**B0100000023be50

```

rz is called, but it doesn't appear to be doing anything. Can someone tell me what is wrong with my code?

Thank you.

---

<div class="post-metadata">

**Author:** ![munkeHoller](https://community.unix.com/user_avatar/community.unix.com/munkeholler/32/7431_2.png) [@munkeHoller](https://community.unix.com/u/munkeHoller)\
**Post date:** [June 1, 2022, 12:57am UTC](https://community.unix.com/t/receive-zmodem/386821/2 "2022-06-01T00:57:20Z")

</div>

@ignatius , hi

what do you expect rz to do ?  
can you show some initial output from an interactive session with rz outside of any c-program

secondly, some of your logic needs refining in the snippet of code shown.  
(it would be helpful to show the entire function this code is part of , makes it easier for the team to assess.

thks

---

<div class="post-metadata">

**Author:** ![ignatius](https://community.unix.com/letter_avatar/ignatius/32/5_5575768a8748004e209b776fc1b2916d.png) [@ignatius](https://community.unix.com/u/ignatius)\
**Post date:** [June 1, 2022, 11:57am UTC](https://community.unix.com/t/receive-zmodem/386821/3 "2022-06-01T11:57:40Z")

</div>

rz is used to download files using the ZModem protocol.

Here's the code.

```nohighlight
static void con_escape(void) 
{
        char b;

        if (bb_got_signal) 
                rawmode();

        full_write1_str("\r\nConsole escape. Commands are:\r\n\n"
                        " d download\r\n"
                        " u uploadd\r\n");

        if (read(STDIN_FILENO, &b, 1) <= 0)
                doexit(EXIT_FAILURE);

        switch (b) {

        case 'u':
                system("sz --zmodem --try-8k --binary --restricted %s");
                break;
        case 'd':

        int zmodem_result=1;
        pid_t childpid;

                if ((childpid = fork()))
                { 
                        execlp("rz","rz",NULL); 
                        perror("exec() of rz failed"); 
                        exit(-1);
                }
                else if (childpid>0)
                        wait(&zmodem_result);
                else perror("fork failed");
                break;
        }

        if (bb_got_signal)
                cookmode();
 ret:
        bb_got_signal = 0;
}

```

"sz" is a place holder. It doesn't actually work.

---

<div class="post-metadata">

**Author:** ![system](https://community.unix.com/uploads/default/original/2X/c/c7e9e16a595259edafe88615719d5c5dcda035c2.png) [@system](https://community.unix.com/u/system)\
**Post date:** [July 31, 2022, 11:58am UTC](https://community.unix.com/t/receive-zmodem/386821/4 "2022-07-31T11:58:32Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
