PDA

View Full Version : missing argument `-exec' (Random MAC)



Sunstarx55
2016-12-05, 01:44
So I'm using DefaultZero's method to generate a random mac:



vi /etc/init.d/macc.sh

***
#!/bin/bash
ifconfig wlan0 down
macchanger -r wlan0
ifconfig wlan0 up***


chmod +x /etc/init.d/macc.sh


update-rc.d macc.sh defaults 100

and I've replaced the starred code with RepZeroWorld's 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:



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:



-exec sh -c "sed -i \"/^cloned-mac-address.*/d;/^\[802-11-wireless\]/a\cloned-mac-address=$random_mac\"\"{}\""\;




\" \"{}\"" \;
^ ^

Feel free to close, I apologise for being blind