小编mmi*_*313的帖子

将多个参数从 Applescript 传递到终端命令脚本

我一直在试图弄清楚如何将多个参数从 Applescript 传递到终端命令脚本。例如,在运行终端命令文件时,您可以像这样以编程方式接收参数:

#!/bin/bash

var=$1

var=$2
Run Code Online (Sandbox Code Playgroud)

我一直在使用的 Applescript 代码如下供参考:

tell application "System Events" to set app_directory to POSIX path of (container of (path to me))

set thisFile to "Dev"

set testTarget to "/Users/lab/Desktop/TestTarget/"

do shell script "/Users/lab/Desktop/TempRoot/mycommand.command " & thisFile & testTarget with administrator privileges
Run Code Online (Sandbox Code Playgroud)

我认为我出错的地方是第二个参数的输入。当我只有一个参数时,它运行得很好:

do shell script "/path/to/command/mycommand.command" &var with administrative privileges
Run Code Online (Sandbox Code Playgroud)

我很好奇传递第二个参数的正确语法是什么。如果有人有任何建议,请告诉我!另外,如果您需要更多信息,我很乐意提供!

parameters macos bash terminal applescript

2
推荐指数
1
解决办法
2032
查看次数

标签 统计

applescript ×1

bash ×1

macos ×1

parameters ×1

terminal ×1