(Apple)script and Terminal....

tismey

Official Bartender
I'm trying to suss out a way of scripting the terminal so that I can generate escape sequences. I have to telnet into some VMS boxes for work, and I'm getting sick of having to remember sequences like <esc>[29~ at 5am.

So, I figured I'd see if the newly applescriptable terminal would let me create something to generate these codes, but I can't seem to work out how to write scripts that apply to already open sessions. Whenever I run a script to tell the terminal to do anything, it opens a new window.

So does anyone know if this is doable? And if so, can someone point me in the direction of something I can look at and learn from?

Ta
 

jackshedd

a bastard.
I think what you are going to want to do is:

1.) Write an AppleScript which stores your needed escape sequence in the clipboard. I'm not infront of my mac right now, but, if you need it, email me later and I will generate the script for you, just let me know what sequence you need.

2.) Have the script simply paste the contents.

3.) Use something like KeyMap X to assign a custom keyboard command to executing the applescript.

And bing! Your done.
 

tismey

Official Bartender
Might just give that a try when I get back to my Mac....
 

simX

Unofficial Mac Genius
I don't think there is a way to have AppleScript put something into the current window. The other limitation is that in Script Editor, it recognizes "\n" as a line break, but sometimes you actually need to use that string in the terminal command, so it's really annoying because you can't use it via AppleScript!

It's nice to be able to control via an AppleScript, but the best way is to make a shell script file and name it "file.command", and then just have AppleScript open up that file from the Finder, which automatically launches Terminal, executes the command in a new terminal window, and then automatically logs out once the command is completed. You still can't get it to apply to an open session, though, unless you can via a UNIX command.
 

tismey

Official Bartender
I've been using shell scripts in a similar way to how you describe, for specific tasks etc. But what I want to do now is basically have an easy way of typing a string of characters that do something specific when I'm telnetted in, and Applescript started to look like my only option.

I wish TypeIt4Me would hurry up - that used to do it no problem.
 
Top