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

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

问题描述

我有谁是get激活不是真的彼此的后面几个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

EDIT2:现在我用这个

For now I use this

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和终端(运行几个做shell脚本在一个终端窗口)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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