3

I have 10 script files and each file contain up to 100 commands ( each command take 1 min ). At the moment it saves me time and I click only one file to execute 100 commands but what I want is another script file which execute 10 script files sequentially instead of me waiting for each to finish and then executing the second script file by clicking it.

1
  • 4
    In bash? I think you can just do this: script0; script1; script2 Commented Jul 14, 2012 at 0:33

2 Answers 2

3

You just call each script as you would before, but seperate them with a semicolon ;

After each script finishes execution, bash will start executing the next script.

In the terminal:

./scriptsrc/script_1; ./scriptsrc/script_2; ./scriptsrc/script_n;

If you need more guidance check this question out, its fairly similar.

EDIT: If you want to run multiple scripts from one other script this can be accomplished by adding the shebang line to tell the kernel the file is executable and then just listing what scripts you want:

#!/bin/bash

./scriptsrc/script_1 
./scriptsrc/script_2
./scriptsrc/script_n

echo "script execution complete"
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, it worked and I can run multiple scripts by typing its name one after the other at command prompt (terminal) but does it mean that we cannot run script files from a script file?
@Asbat you can indeed run them from a script file, you just need to ad the shebang line ( #!/bin/bash ) and then call each script on a seperate line without the ; please look at the edit.
I have no issue running the scripts in the terminal but once I try to run them in a separate script I get a "Permissions Denied issue" any reason? I dont have an sudo settings on the script prior.
0
set a to alias POSIX file "/Users/Firebird/Documents/script1.scpt"
set b to alias POSIX file "/Users/Firebird/Documents/script2.scpt"
set c to alias POSIX file "/Users/Firebird/Documents/script3.scpt"

set theScriptFiles to {a, b, c}
repeat with scriptFile in theScriptFiles
    run script scriptFile
end repeat

The last script on the list didn't run the first couple of times when I was testing for an unknown reason, but after I ran

set myList to {"Hello", "Goodbye", "I must be going"}
repeat with theItem in myList
    say theItem
end repeat

it worked!

To make sure all the scripts ran I tell Texteditor to open a file for each corresponding script:

tell application "Finder" to open "Macintosh:Users:Firebird:Documents:ranscript1.rtf"

This thread is really good too from MacScripter http://macscripter.net/viewtopic.php?id=44260

Comments

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.