0

Morning Folks,

think this is my first post of the new year, so Happy New Year.... i have got a small applescript i have written (see below), it is connecting to a telnet session, but opens two terminal windows - one is just a terminal window and the other is the telnet session...any ideas on how i can remove the first winow opening to just leave the actual telnet session??

set telnet to "telnet -K 0.0.0.0
tell application "Terminal"
run
do script telnet
delay 1
end tell


Thanks a lot

gn0m3

Attachments screendump.jpg 25.06 KB
3
Contributors
7
Replies
8
Views
10 Years
Discussion Span
Last Post by gn0m3
0

try adding this after the 'run' statement:

tell application "System Events"
tell process "Terminal"
keystroke "w" using {command down}
end tell
end tell

when the run statement is given, it opens Terminal, which by default opens a new sessions window. The above code sends the command-w keystroke to the terminal app via a system event (same as a live keystroke) and will close the open window. Good luck.

0

Just change the script to read

[tell application "Terminal"
activate
end tell
delay 5
tell application "System Events"
if UI elements enabled then
tell process "Terminal"
set frontmost to true
end tell

keystroke "telnet -K 0.0.0.0"

key down return
key up return

end if
end tell]

Type the text in the [] in script editor and it will tell terminal to try to connect to 0.0.0.0. You can change it to whatever you want. This script basically just presses the keys on the keyboard for you. (And you only have one window open on the run)

Hope that works :)

0

thanks for that guys, will try it out later, have been off ill for the last week so sorry for not responding...

gn0m3

0

thanks Lomoco, that worked great. Thanks also for your suggestion cryptq, but when run the front window got closed down which was the window i needed, i tried playing around with the code but could not get to function..

Thank you both.

gn0m3

0

Oh, and be sure not to do anything while the script is running. It may cause your computer to start acting funny. If this occurs, save whatever you were working on by using the MENUS and log-out. What happened is that a key that applescript pressed didn't get let up and is still being held down virtually. Experiment with the script I gave you to get the best result for you.

0

try adding this after the 'run' statement:

tell application "System Events"
tell process "Terminal"
keystroke "w" using {command down}
end tell
end tell

when the run statement is given, it opens Terminal, which by default opens a new sessions window. The above code sends the command-w keystroke to the terminal app via a system event (same as a live keystroke) and will close the open window. Good luck.

Modify your command-w script to read the following:

tell application "System Events"
tell process "Terminal"
keystroke "`" using {command down}
keystroke "w" using {command down}
end tell
end tell

That should work for you

0

thanks once again for your help on this one guys, another problem solved.

gn0m3

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.