Results 1 to 1 of 1

Thread: missing argument `-exec' (Random MAC)

  1. #1
    Join Date
    2016-Dec
    Posts
    3

    missing argument `-exec' (Random MAC)

    So I'm using DefaultZero's method to generate a random mac:

    Code:
    vi /etc/init.d/macc.sh
    ***
    Code:
    #!/bin/bash
    ifconfig wlan0 down
    macchanger -r wlan0
    ifconfig wlan0 up
    ***

    Code:
    chmod +x /etc/init.d/macc.sh
    Code:
    update-rc.d macc.sh defaults 100
    and I've replaced the starred code with RepZeroWorld's code:

    Code:
    #!/bin/bash
    ifconfig wlan0 down
    random_mac=`macchanger -r wlan0|sed -n 's/^New *MAC: \([[:alnum:]].*[[:alnum:]]\) .*/\1/gp'`;
    find /etc/NetworkManager/system-connections -type f -exec sh -c "sed -i \"/^cloned-mac-address.*/d;/^\[802-11-wireless\]/a\cloned-mac-address=$random_mac\" \"{}\"" \;
    Everything seems fine, I reboot to activate it and the mac does not change. I try to do it manually by:

    Code:
    cd /etc/init.d/
    sh macc.sh
    and it returns
    find: missing argument to `-exec'
    The only change I've made it the 'wlan0' to 'wlan1' to match my device.

    Am I just missing something really obvious?

    If no one can find a problem with what I've done there ^ I'll screenshot the file when I'm back at my laptop.

    Thanks

    EDIT:

    Ugh, I was missing two spaces:

    Code:
    -exec sh -c "sed -i \"/^cloned-mac-address.*/d;/^\[802-11-wireless\]/a\cloned-mac-address=$random_mac\"\"{}\""\;
    Code:
    \" \"{}\"" \;
      ^       ^
    Feel free to close, I apologise for being blind
    Last edited by maiki; 2016-12-06 at 11:42. Reason: Merge posts

Similar Threads

  1. Replies: 8
    Last Post: 2013-06-20, 08:45

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •