Use Applescript to run a terminal command

Status
Not open for further replies.
Joined
Jan 30, 2009
Messages
48
Reaction score
0
Points
6
I have a Terminal command and associated password to execute the command (a command and a password) I must run dozens of times a day. Bored of doing it hand 1 by 1.

So, I started writing an Applescript (that I will turn into an Application so I can just click it to execute all in 1 click) that opens terminal, enters the command BUT the command is only executed if I enter the necessary password. but, that is where I am stuck. I can open terminal, have it enter the command, but I am not sure how to then follow-up with the password to execute the command when prompted. Here is what I have and it works perfect

tell application "Terminal"
activate
do script "blahblahblahblahblah" in front window
end tell


I have tried these variations, but no luck

do script "blahblahblahblahblah" password "passwordhere" in front window - as a means of entering script and the password in 1 shot
do script "passwordhere" in front window - as a means of then entering the password after first script runs

so, not sure how to get it to follow up the command at the password prompt that comes up and enter the password. Yes, I will keep working on it.. but if you can see the fix, please advise.
 
OP
T
Joined
Jan 30, 2009
Messages
48
Reaction score
0
Points
6
I was soooo close...

what I needed was

delay 1 -- pause for a second

after the first command and then execute the second password command do script "passwordhere" in front window
 
Status
Not open for further replies.

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top