使用applscript执行dig并启动远程桌面

发布于 2024-10-20 16:29:46 字数 208 浏览 1 评论 0原文

我不知道 applescript,但我需要自动化执行以下步骤,看来 applsescript 是正确的选择。

1)运行终端命令“dig @123.4.5.678 computername.domain.net +short” 2)捕获返回的IP地址 3) 启动 Microsoft 远程桌面并传入捕获的 IP 地址。

这可能吗?我使用什么命令?有什么地方有好的教程吗?

I don't know applescript, but I need to automate the following steps, and it seems that applsescript is the way to go.

1) run the terminal command "dig @123.4.5.678 computername.domain.net +short"
2) Capture the returned IP address
3) Launch Microsoft remote desktop passing in the captured IP address.

Is this possible? what commands do i use? Is there a good tutorial somewhere?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

肥爪爪 2024-10-27 16:29:46

要从Applescript运行shell脚本,您可以使用命令

do shell script“mycommand”,

其中mycommand是您正在执行的shell命令。

微软的远程桌面可能无法编写脚本。 (我不使用它,也不能说)但是您可以使用所谓的 GUI 脚本来编写其他应用程序的脚本。

然后,您可以有一个类似这样的脚本(注意未经测试)

set a to do shell script "myscript"
tell application "Finder" to set the clipboard to a
tell application "Remote Desktop Connection" to activate
tell application "System Events"
    tell process "Remote Desktop Connection" to keystroke "v" using command down
end tell

GUI 脚本基本上告诉 RDC 将剪贴板粘贴到您的 IP 字段中。

有关 GUI 脚本编写的教程可以在这里找到:

http://www.macosxautomation.com/applescript /uiscripting/index.html

有很多通用的 Applescript 教程,例如:

http://homepage.mac.com/swain/Macinchem/Applescript/AppScript_tut/AppScrip_tut_1/appscript_tut_1.htm

To run a shell script from Applescript you use the command

do shell script "mycommand"

where mycommand is the shell command you are executing.

Microsoft's Remote Desktop is probably not scriptable. (I don't use it and can't say) However you can use what is called GUI scripting to script other applications.

You could then have a script somewhat like this (note untested)

set a to do shell script "myscript"
tell application "Finder" to set the clipboard to a
tell application "Remote Desktop Connection" to activate
tell application "System Events"
    tell process "Remote Desktop Connection" to keystroke "v" using command down
end tell

The GUI scripting basically tells RDC to paste the clipboard into the field for your IP.

The tutorial on GUI scripting can be found here:

http://www.macosxautomation.com/applescript/uiscripting/index.html

There are lots of general Applescript tutorials such as here:

http://homepage.mac.com/swain/Macinchem/Applescript/AppScript_tut/AppScrip_tut_1/appscript_tut_1.htm

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文