applescript 和终端(在一个终端窗口中运行多个 do shell 脚本) [英] applescript and terminal ( run several do shell script in one terminal window )

查看:79
本文介绍了applescript 和终端(在一个终端窗口中运行多个 do shell 脚本)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确实有几个 shell 脚本,它们被激活并没有真正相互落后.

I do have several shell scripts whom are get activate not really behind each other.

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

But I want to stay in the same terminal window.

为了简化问题,我们举个例子

To simplify the problem, lets say that as example

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

first script. - cd to the working directory second. - do some things and get files from that directory third. - dome more thing on the newly files/folders in that directory. fourth. - ....

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

How can I let script 2 and 3 ( all the script thus ) run in that very same directory and window that is opened during script 1?

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

F.e how can I avoid using the full path to that folder for every file.

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

After adayzdone's answer I realize that I forgot to mention that I need also administrator privileges for one of the scripts

现在我用这个

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

但仍然没有拥有特权的骰子.

but still no dice with the privileges.

推荐答案

尝试:

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

这篇关于applescript 和终端(在一个终端窗口中运行多个 do shell 脚本)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆