Terminal Services

mromey

Registered
How do you use terminal services? Has anyone had any luck? Can anyone share some examples or explain how the exsisting examples work? I tried to apply a terminal service to a field in the address book application but I didn't understand the data it returned. How do I learn how to make my own custom scripts? Should I learn more about Unix or do I need to learn a scripting language? Ideally I need to figure out how to take a piece of data from a field in an application on the mac and send it to another computer via some type of tcp connection in a terminal. For example:

1. I need to rlogin to another computer
2. Navigate to a particular directory on this remote computer
3. send a data string containing data from a field on the mac to an application located in this remote directory via a macosx termianl

% ev_send -p 6900 'RENDERER*STAGE START apple'
(apple being the piece of data from the mac application)

Right now it is pretty simple for me to open up a terminal and do this hole procedure manually but I would like to set up a terminal service to do this automatically.


Mike Romey
 
Here's a start, but I'm no scripting master.

Terminal services take the hilighted text and use that as a parameter passed to a CLI program. For example, I believe the "count words" service just takes the text and sends it to some permutation of grep, etc.
Looking in the terminal prefs under services you can see what CLI programs are being run with that particular input.

Now, what you need to do is make a shell script that takes one line of input as a parameter. This script needs to automate the rlogin, etc, process, and then run the remote program with the line of text you passed to the script. (Is this even possible? I am unsure of how shell scripts interact with rlogin... this is not my forte.)

Finally, you need to add a terminal service that feeds selected text to your shell script. This should do it.

So, you need to do a few things: 1) Play with the terminal services until you feel comfortable with them and the options. 2) Play with shell scripts until you can make one do what you want. Fortunately, there are many FAQs about shell scripting. Or you could do it in perl, perhaps?

Hopefully some other people will supplement this post with more details about shell scripting.

Zach
 
There is a tool that can automate keystrokes in a terminal and can enhance shell scripting greatly when you want to automate commands across several login sessions. Some Linux distributions have it already installed (I'm pretty sure it's on LinuxPPC), but I'm not aware of it being ported to Darwin/MacOS X.

But if you want to give it a shot (I'm going to try compiling it myself) it's called Expect and you can find it at: http://expect.nist.gov/

It's very powerful, if at times a little bewildering. It uses (and requires) TCL which is a fairly simple language to learn. You can also download TCL at the same site.

I've got to admit, it has saved me hours of work.

Dave
 
I can confirm that Expect compiles fine. But you do need to first compile and install the Libc from Apple's Darwin source code.

Dave
 
Back
Top