newbie question about PUTTING TEXT IN AN APP

look, I want to open an app, put a text in, press enter and then hide the app.

yes, you guessed right, I’m trying to make a Script for the Terminal application.

open application “Terminal”

and then? I try anything; display; print; put; etc BUT Applescript keep thinking the text TO PUT IN THE TERMINAL is an action that Applescript has to do, and not a text to put in Terminal…
also, the text I want to put in it, has an “ENTER” at a certain point, and I’m sure that AppleScript will take it as an “end”…

and when I try to “record, please”, it records only the changes in Applescript, not anywhere else.

WHAT AM I SUPPOSED TO DO?

btw if you need the text or the app I’m trying to make work, send me an e-mail, I will explain you the rest there, and please only help me if you are sure it’s going to work.

Welp, I’m totally confused. I’m not sure what you are asking, but here’s a stab in the dark…

tell application "Terminal"
	activate
	do script "echo look, put a text in it"
end tell

What is “record, please”?

LoL sorry, it’s my habit, that’s what I say when I click on the “record” button

=> “record”, next to “stop” and “execute”

anyway, thanks, I’ll try

brb

well, any normal text would be put, no problem, BUT !

what I have to put in as text has “” and " " (spaces), and it seems that Applescript won’t read it !!

why can’t Applescript let it go and just put in the Terminal what I tell him to put? :cry:

You need to “escape” some characters when passing them to the shell.

tell application "Terminal"
	activate
	do script "echo This is some text //slash// \\\\here\'s more text"
end tell

If you try to run

echo This is some text, here's some more text

in the shell, it will error too. Again, the characters with special meaning have to be escaped…

echo This is some text, here's some text

To run the same line from AppleScript, you’ll need to escape them prior to passing it to the shell as in…

tell application "Terminal"
	activate
	do script "echo This is some text\, \\here\'s more text"
end tell
-->This is some text,  here's more text

“Why can’t AppleScript…” AppleScript is simply doing what you are asking it to do, the trick is knowing how to ask.
You’ll get a lot more help if you can post the code you are having trouble with.

How 'bout this?

Jon

I will try all that, but later, it’s 1 AM here…

here is the exact piece of text I want to put, and it seems that Apple works can’t understand that I want the “” and the " " as a caracter of the text to paste, not as an Applescript commant.
from here

cd /Applications/dMSN Messenger
java -classpath lib/dMSN.jar:lib/Encryption.jar:lib/Layout.jar:lib/Skins2.jar:lib/CPU.jar::lib/Skins.jar:lib/XML.jar:lib/TrayIcon.jar:lib/Pop3.jar
com.Danny.Net.MSN.Main -messenger

to there

my current testes looks like:

tell application “Terminal”
activate
do script “cd /Applications/dMSN Messenger
java -classpath lib/dMSN.jar:lib/Encryption.jar:lib/Layout.jar:lib/Skins2.jar:lib/CPU.jar::lib/Skins.jar:lib/XML.jar:lib/TrayIcon.jar:lib/Pop3.jar
com.Danny.Net.MSN.Main -messenger”
end tell

but from the first “” it won’t work, and I need to keep the exact text to make the Terminal work properly.

thanks for the replies untill here tho’[/i]

s_kalb wrote: my current testes looks like: :D:D

tell application "Terminal" 
         activate 
         do script "cd /Applications/dMSN Messenger 
         java -classpath lib/dMSN.jar:lib/Encryption.jar:lib/Layout.jar:lib/Skins2.jar:lib/CPU.jar::lib/Skins.jar:lib/XML.jar:lib/TrayIcon.jar:lib/Pop3.jar 
         com.Danny.Net.MSN.Main -messenger" 
 end tell

Try this, your “” needs to be escaped before passing the command to the terminal.app. Note the double backslashes “dMSN\ Messenger”…

tell application "Terminal"
	activate
	do script "cd /Applications/dMSN\ Messenger java -classpath lib/dMSN.jar:lib/Encryption.jar:lib/Layout.jar:lib/Skins2.jar:lib/CPU.jar::lib/Skins.jar:lib/XML.jar:lib/TrayIcon.jar:lib/Pop3.jar 
com.Danny.Net.MSN.Main -messenger"
end tell

I do not have dMSN Messenger, so I can not test this. You may have to add a semicolon between the commands…

do script "cd /Applications/dMSN\ Messenger;  java -classpath...