0

This question already has an answer here:

I am running the following script in Platypus but the MAC address does not change:

#!/bin/zsh

IF=en7

mac=`ifconfig $IF | awk '/ether/{print $2}'`
echo "$IF mac before change=$mac"
randmac=`openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`
sudo ifconfig $IF ether $randmac
mac=`ifconfig $IF | awk '/ether/{print $2}'`
echo "$IF mac after change=$mac"

Not receiving errors anymore. However, the MAC address is not changed by the script. Commands work individually pasted into Terminal, but not executed as an application by Platypus.

Platypus screenshot:

Platypus screenshot

marked as duplicate by Graham Miln, user3439894, Nimesh Neema, Mark, Allan Nov 9 '18 at 14:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Can you please fix your code formatting by editing your question, selecting the bash script and clicking on the „{}“ in the bar on top of the edit box? – nohillside Nov 9 '18 at 8:17
  • What part do you need help with? Does the shell script work? – Graham Miln Nov 9 '18 at 10:31
  • Your script code has a bunch of smart-quotes and you should use straight-quotes. Also, needless use of grep | when ifconfig $IF | awk '/ether/{print $2}' does both. – user3439894 Nov 9 '18 at 17:21
0

Platypus

Use Platypus to create an application from your bash script. This approach avoids needing to use AppleScript.

Platypus is a developer tool that creates native Mac applications from command line scripts such as shell scripts or Perl, Ruby and Python programs. This is done by wrapping the script in a macOS application bundle along with an executable binary that runs the script.

Platypus screenshot

Other Approaches

Mathias Bynens has an article on How to create simple Mac apps from shell scripts.

Also worth reading is the related question How to make a Mac OS X .app with a shell script?

  • 1
    Your answr is better than the platypus one in the duplicate It would b nice if this was moved to the original – Mark Nov 9 '18 at 11:00
  • If the error is related to the script not working, ask a new question specifically about the error. Otherwise, can you edit this question? – Graham Miln Nov 9 '18 at 17:36
  • Graham - I used Platypus to create an application out of the script above. The script runs error free, but the MAC address does not get changed. Can you help me understand why that is happening? I am running Mojave 10.14.1. Commands work when run individually in Terminal, but not when compiled as an app. – isd503 Nov 10 '18 at 19:50
  • sudo in your script requires root privileges. The script has no error checking, so you be getting errors but not seeing them. – Graham Miln Nov 11 '18 at 9:16

Not the answer you're looking for? Browse other questions tagged .