gpt4 book ai didi

bash - applescript 和终端(在一个终端窗口中运行多个 do shell 脚本)

转载 作者:行者123 更新时间:2023-11-29 09:32:10 25 4
gpt4 key购买 nike

我确实有几个 shell 脚本,它们被激活并没有真正落后于彼此。

但我想留在同一个终端窗口中。

为了简化问题,举个例子

第一个脚本。 - cd 到工作目录第二。 - 做一些事情并从该目录中获取文件第三。 - 在该目录中的新文件/文件夹上添加更多内容。第四。 - ....

如何让脚本 2 和 3(所有脚本)在脚本 1 期间打开的同一目录和窗口中运行?

F.e 如何避免为每个文件使用该文件夹的完整路径。

编辑:在 adayzdone 的回答之后,我意识到我忘了提到我还需要其中一个脚本的管理员权限

EDIT2:现在我用这个

tell application "Terminal"
set newTab to do script
set current settings of newTab to settings set "Grass"
do script "bin/sh/ echo 'xx' | su;" in newTab
do script "cd " & quoted form of realParentPath in newTab
do script shellscript1 in newTab
do script shellscript..n in newTab
activate
end tell

但仍然没有特权。

最佳答案

尝试:

tell application "Terminal"
do script "cd ~/" in window 1
do script "ls -a" in window 1
end tell

property usr : "username"
property pswd : "password"

set xxx to do shell script "cd ~/ ; ls -a " user name usr password pswd with administrator privileges

关于bash - applescript 和终端(在一个终端窗口中运行多个 do shell 脚本),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13090235/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com