Search code examples
linuxexecexecl

execl off by two bytes


I have this code:

    execl("/bin/ip", "address", "add", 
        "dev", ob->tun_name,  
        "local", ob->local_ip,
        "peer", ob->remote_ip,
        NULL
    );

But I get the error:

Object "dress" is unknown, try "ip help".

If I use this:

    execl("/bin/ip", "  address", "add", 
        "dev", ob->tun_name,  
        "local", ob->local_ip,
        "peer", ob->remote_ip,
        NULL
    );

It works.

I've tried execlp("ip", ... but it has the same problem.

What am I doing wrong - why do I need to throw away two characters in front of "address"?


Solution

  • This works, I needed to add the name of the executable back in.

        execl("/bin/ip", "/bin/ip", "address", "add", 
            "dev", ob->tun_name,  
            "local", ob->local_ip,
            "peer", ob->remote_ip,
            NULL
        );