Entering keystrokes in Terminal.

Is is possible to enter custom keystrokes in Terminal? I have a command line program that requires me to enter a local password to update a report. Is it possible to applescript that local password? This password is different than the admin/root password. For instance, let’s say I wanted to enter the keystrokes ‘Ilovemacscripter.net’. I have searched the BBS and have found nothing regarding this topic. Thanks in advance for the help.

Will this do what you expect?

set pswd to do shell script "echo Ilovemacscripter.net"

Mr. Spence,
It doesn’t seem to work. Terminal comes up with the prompt ‘password:’ and then it waits for me to enter my password. Is it possible that I have to enter in the command you’ve given. Or is that what echo does?

All ‘echo’ does is place the text after the echo command in the terminl.app window. You can open the terminal and type

echo here is some text
echo here's some text
echo "here's some text"

to see what I mean. As far as using it for an interactive command like you need, you may be out of luck, see…

http://developer.apple.com/technotes/tn2002/tn2065.html#Section5

Mr. Spence,
Thanks for the suggestion. I’ve modified the code and found this to work for me:


I no longer have to enter my password which automates the task for me. Again thanks for the suggestion.

Thanks for posting your solution David, maybe it will help someone else with a similar problem.

I was to hasty in my reply. My code didn’t work. I’ll keep trying.

David, you can also look at the unix manual for ‘printf’ – man printf. It allows you to add controls that may help, such as r for a return or n for a new line etc. Agian I’m not sute if you will be able to get it to work, but it’s worth a try. example

printf "usernamerpassword"