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.
2 Answers
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"
3 Comments
#!/bin/bash ) and then call each script on a seperate line without the ; please look at the edit.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
script0; script1; script2