bash - osascript 语法错误“预期的表达式,但发现行尾。(-2741)”
问题描述
我正在编写一个使用 AppleScript 禁用麦克风和摄像头的 bash 脚本,然后单击 google meet 网页上的“立即加入”按钮。禁用麦克风和摄像头的部分运行良好,但我遇到了用于单击加入按钮的脚本部分的问题。这是脚本:
#!/bin/bash
osascript <<EOF
tell application "System Events"
delay 4
key code 14 using command down
delay 1
key code 2 using command down
delay 1
end tell
EOF
#the following is not working-
osascript <<EOF
tell application "brave"
tell active tab of window 1 to -
execute JavaScript "document.getElementById('Join now')[0].click();"
end tell
EOF
当脚本的第二部分尝试执行时,我收到此错误:
62:63:语法错误:预期表达式但找到行尾。(-2741)
如何修复此错误并让脚本正确执行(单击按钮)?
解决方案
之后您没有正确的行继续符to
:
tell active tab of window 1 to -
使用:¬
,例如:
tell active tab of window 1 to ¬
可以通过在Script Editor中键入来创建行继续符。optionL
如果仍然抛出错误,则将其全部放在一行中,例如:
tell active tab of window 1 to execute JavaScript "document.getElementById('Join now')[0].click();"
推荐阅读
- azure - 在 Azure PowerShell 中将输出设置为表格格式而不是 json
- python - pd.Series 字符串替换意外修改值
- c - 负整数的二进制补码是否仅用于加法和减法?
- machine-learning - 从两个不同的来源训练和测试机器学习
- webpack - HtmlWebpackPlugin 没有缩小脚本标签
- c# - 使用 ASP.NET Web API 向数据库添加数据时出现 SQL Server 错误
- ruby-on-rails - form_for 嵌套路由 url 生成错误
- symfony - 使用 symfony LoginFormAuthenticator 和 lexik_jwt_authentication 来处理管理员用户和 api 令牌
- javascript - 无法从我的 js 文件中使用 firebase.auth
- python - 是否可以使用邻居数组执行广度优先搜索?