我正在使用以下 AppleScript 来通过 netcat 控制 Blackmagic Design Videohub 路由器,但我遇到了一些麻烦。我似乎无法将端口正确传递给 netcat。我当前的错误是nc:端口范围无效。出于这篇文章的目的,我删除了设备名称和 IP。有什么想法吗?
display dialog "Choose an option:" buttons {"Live", "Cut to Channel"}
set userChoice to button returned of result
on sendCommand(IP, port, command)
do shell script "printf " & quoted form of command & " | nc " & IP & " " & (port as string)
end sendCommand
on checkACK(reply)
if reply contains "NAK" then
display dialog "Error: " & reply
end if
end checkACK
if userChoice is "Live" then
--Clean Switch commands
set CleanSwitchIP to "[IP]"
set CleanSwitchPort to "[Port]"
set commands to "VIDEO OUTPUT ROUTING:\\n0 1\\n2 1\\n3 1\\n6 1\\n7 1\\n8 1\\n9 1\\n10 1\\n11 1\\n"
set reply to sendCommand(CleanSwitchIP, CleanSwitchPort, commands)
checkACK(reply)
-- Video Hub commands
set VideoHubIP to "[IP]"
set VideoHubPort to "[PORT]"
set command to "VIDEO OUTPUT ROUTING:\\n24 12\\n"
set reply to sendCommand(VideoHubIP, VideoHubPort, command)
checkACK(reply)
-- Video Hub 2 commands
set VideoHub2IP to "[IP]"
set VideoHub2Port to "[PORT]"
set commands to "VIDEO OUTPUT ROUTING:\\n13 30\\n14 30\\n15 30\\n16 30\\n20 30\\n22 30\\n23 30\\n24 30\\n25 30\\n27 30\\n"
set reply to sendCommand(VideoHub2IP, VideoHub2Port, commands)
checkACK(reply)
display dialog "You are now Live to the studio!"
else if userChoice is "Cut to Channel" then
-- Clean Switch commands
set CleanSwitchIP to "[IP]"
set CleanSwitchPort to "[Port]"
set commands to "VIDEO OUTPUT ROUTING:\\n0 0\\n2 0\\n3 0\\n6 0\\n7 0\\n8 0\\n9 0\\n10 0\\n11 0\\n"
set reply to sendCommand(CleanSwitchIP, CleanSwitchPort, commands)
checkACK(reply)
-- Video Hub 2 commands
set VideoHub2IP to "[IP]"
set VideoHub2Port to "[Port]"
set commands to "VIDEO OUTPUT ROUTING:\\n13 30\\n14 30\\n15 30\\n16 30\\n20 30\\n22 30\\n23 30\\n24 30\\n25 30\\n27 30\\n"
set reply to sendCommand(VideoHub2IP, VideoHub2Port, commands)
checkACK(reply)
end if
我尝试了几种不同的方式来声明端口,但没有任何运气。