3

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

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. - ....

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 how can I avoid using the full path to that folder for every file.

EDIT: 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.

1 Answer 1

1

try:

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

OR

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

set xxx to do shell script "cd ~/ ; ls -a " user name usr password pswd with administrator privileges
Sign up to request clarification or add additional context in comments.

6 Comments

Thank you, did help already. However, I need also administrator privileges for one of the scripts. But I can't find/don't know a way how to add privileges or should I use "echo $passw | sudo -u root" in my shell script
Is there a reason you need to run it from Terminal and not with do shell script?
With do shell script I have no common shell, f.e Cd in the first do shell script isn't of any use in the 2'nd do shell script. Am I right or... Second reason, I like to see also visual some results of the script without logging per se. But Anyway, if You can tell me how I can solve the CD issue, I can use that in an other script. Thanks again. BTW, with the privileges issue, I see I lost a line in my comment that I always get the 'sorry' as result.
Thank you. Yes but thats with "do shell script" and not with "do script", and will loose the CD path.
as long as you separate the commands with a ; as I did in my answer, you will not loose the CD path.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.