【发布时间】:2019-04-07 19:41:19
【问题描述】:
我在 bash 中有一个程序可以更改我显示的 MAC 地址。我想用“do shell script”把这个程序变成一个applescript。但是,每当我在“do shell script”函数中运行代码时,它都不起作用。这很奇怪,因为它在终端中工作。
这是在我的 Mac 计算机上,我认为这是“执行 shell 脚本”功能后所需引号的问题。我尝试过更改报价顺序,但似乎不起作用。
sudo ifconfig en0 ether "$(openssl rand -hex 6 | sed 's/../&:/g;s/:$//')"
这是基本代码
do shell script "sudo ifconfig en0 ether "$(openssl rand -hex 6 | sed 's/../&:/g;s/:$//')"" with administrator privileges
这是此代码的 AppleScript 变体。
预计此代码会更改我的 MAC 地址,但它返回了“错误 -212”
【问题讨论】:
标签: bash applescript sudo quotes