So i'm trying to write a simple script that opens terminal, ssh onto a server and does stuff while it's there.
tell application "Terminal"
Activate
do script "cd documents"
delay 2
do script "ssh private key user@server"
delay 6
do script "while true; do curl..."
end tell
How do i get it all in one terminal tab? Currently it opens separate windows for each command
EDITING A SCRIPT You are going to edit it so that it can actually open the fragment editors of each of the selected sequences. From the AppleScript Editor File menu choose Open and locate the script called "Edit this Script" inside the Sample Data's AppleScript folder. Select the script and click the Openbutton.
In the Script Editor app on your Mac, click the Run button in the toolbar, or press Command-R, to execute the commands in your script.
Try:
tell application "Terminal"
reopen
activate
do script "echo \"commmand one\"" in window 1
do script "echo \"commmand two\"" in window 1
end tell
Another way is to use semicolon to concatenate two commands, like this:
tell application "Terminal"
activate
do script "echo \"commmand one\"" & " ; " & "echo \"commmand two\""
end tell
I used &
symbol to demo concatenation in case the "echo \"commmand one\"" is a variable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With