Pipe MacOS stuff through Unix with Terminal services!

johnj1

Registered
If you love the mac and unix, you *must* check out the terminal services. Startup terminal, and leave it running. From its app menu, select "terminal services." This will install some cool utils. Go to TextEdit, its app menu, and then choose from the variety of Terminal Services. Now you can pipe your TextEdit document through sort, sed, perl, or just about any other unix program! Select some files, and then grep some info in them! You can choose to return the text, effectively redirecting the stdout stuff to the window you're working in, or discard the output, or whatever.

Doesn't work in IE, though, since IE dims out the services command :(
 

wmoss

Registered
Wow! I haven't tried this yet but it sounds really cool. Is it possible to pipe standard error as well as in and out?

I also saw a post about AppleScript being able to go one way (able to interact from the command line with AppleScript) and that the engineers intended to get in to work the other way (able to send stuff to the command line from AppleScript) before final ships.

These facilities are sounding very nifty to a guy who likes to screw around in the command line Unix environment but who still has bad memories of ed, vi, and emacs from college :)
 

Gee4orce

Registered
I saw this but I wasn't able to get it to work - I tried selecting text in TextEdit, and choosing 'sort' but nothing happened.

Has fantastic potential though...
 

johnj1

Registered
There are a couple of things you can try:

1. In the terminal services window, you can select whether a command can accept plain text, rich text, or a file. Try turning your text into plain text in TextEdit.

2. I noticed that Terminal services don't immediately go active once you've created them. You may have to log out/in for them to work, or restart. I'm not completely sure.

This certainly merits more poking around.

I don't know if you can pipe stderr yet. I'm guessing adding "2> somefile.err" would redirect to somefile.err, but I'm not sure if you can redirect stderr back to the current window. Maybe "2>stdin" would do the trick?
 

eucci

Registered
Services (of the Cocoa\NeXTStep variety) might not (yet) be available to Carbon applications. I haven't seen them in any yet. :\
 

latourfl

Registered
Originally posted by johnj1
I noticed that Terminal services don't immediately go active once you've created them. You may have to log out/in for them to work, or restart. I'm not completely sure.

This certainly merits more poking around.
If you noticed, there is a "command" at the startup saying "starting services" or something like that. So services are activated when you restart I guess.

I truly think that Services are really really powerful. I'd like to see plenty of them. Imagine, you select some text, then you spelling app offers to correct it, your mail app offers to send it to a friend, speach app offers to read it, scrapbook (where the hell is it!!!) offers you to keep it, HTMLEdit offers you to convert it in HTML source code or to add it as a part of an alredy existing page, QT offers you to display it like a generic, or even to set Victoria high quality to sign your phase and add a new sound track to your favorite instrumental MP3!!!

No exaggeration, IT IS POWERFUL! Micro$$$oft talks about application as a service, and Apple talks about getting services from your apps. We can recognize them both in what they have to offer!!!


But then, how can we reveal (or activate) their power, I'd like to know!
 

latourfl

Registered
Originally posted by latourfl
Originally posted by johnj1
I noticed that Terminal services don't immediately go active once you've created them. You may have to log out/in for them to work, or restart. I'm not completely sure.

This certainly merits more poking around.
If you noticed, there is a "command" at the startup saying "starting services" or something like that. So services are activated when you restart I guess.

I truly think that Services are really really powerful. I'd like to see plenty of them. Imagine, you select some text, then you spelling app offers to correct it, your mail app offers to send it to a friend, speach app offers to read it, scrapbook (where the hell is it!!!) offers you to keep it, HTMLEdit offers you to convert it in HTML source code or to add it as a part of an alredy existing page, QT offers you to display it like a generic, or even to set Victoria high quality to sign your phase and add a new sound track to your favorite instrumental MP3!!!

No exaggeration, IT IS POWERFUL! Micro$$$oft talks about application as a service (and will earn a lot of money from idiots - but MS is not the case here), and Apple talks about getting services from your apps. We can recognize them both in what they have to offer!!!


But then, how can we reveal (or activate) their power, I'd like to know! [/B]
 

zpincus

Registered
AFAIK, Terminal Services do not function unless the terminal is already running. This took me forever to figure out, because I usually have terminal running anyway.

Why they do not start the terminal up when they are called (or why they need the terminal running in the first place) is beyond me. People should report it to Apple (I have, extra requests never hurt.)

If anyone knows how to make them work without the Terminal running, I would be interested in knowing that.

Zach
 

zpincus

Registered
Here are my $.02 on how the "services" could become a valuable tool.

So for Apple to do, in what I consider order of importance: (all of this is just tenered as discussion fodder only...)
1) Make them work with carbon apps. Especially the finder/desktop.
2) Provide an easy interface for people to make their own. Is is already possible to make an applescript service? If not, this neds to be easy. Setting up terminal services to do things in Aqua is very hard and often impossible for what would be a trivial applescript. (Best would be an easy way to link a service with any executable or shell or python or perl or apple scrpt, and to have some control over values get passed to the programs/scripts).
3) Throw them into the underutilized contextual menu. Be smart about it, and only offer sensible options. Ie. when text is hilighted, only show services that take text. If a file is hilighted in the finder, the service should be passed the (full?) pathname. (Imagine right clicking on a folder, choosing "new shell here," and having the terminal pop up a shell already cd'd to that folder?)
4) An easy, customizable way for users to manage and control the services, a la "extension manager" where you can install new ones, turn off ones that just waste menu space, etc.

These features would turn services into something that I would really be able to use to my advantage.

zach
 

iRock

Registered
hmm, ok, in my services submenu i have stuff for Disk Copy, Grab, OmniWeb, and TexEdit. Supposidely mail has services, and as mentioned earlier terminal. When i go to terminal services i get the list of services that are available, but none actually suddenly show up. any ideas how to get these to install themselves?
 

zpincus

Registered
As far as I can remember, you just open the terminal services
window, click "OK" to the "load a bunch or examples" dialog
and then just close the window. Maybe you need to restart
the terminal app or the app that you want to "recieve" the
service, but I don't remember any extra steps beyond that.

zach
 

latourfl

Registered
Originally posted by zpincus
Maybe you need to restart
the terminal app or the app that you want to "recieve" the
service, but I don't remember any extra steps beyond that.

zach
I'm quite sure you need to restart. In fact, the startup "process" indicates "Starting Service Applications". Think it is related to that... And if you want to make them accessible, the Terminal need to be open... Even if in the Service menu items seems to be accessible,choosing it won't launch the Terminal by itself...

But if you want to add a new item to the menu, there's a strange behavior... When saving, the content of the script return back to what it was before the modification. Anyone seeing the same thing?

And is there a way to activate other services like Mail?

[Edited by latourfl on 12-19-2000 at 10:00 PM]
 

iRock

Registered
yup yup, you must restart to enable services for a new application (ie terminal). Once it is enabled though you can adjust the services and you don't have to restart. I'm still looking for how to enable the mail services. I know there are or at least will be services because while trying to learn more about enabling the terminal services i read the mac help files that if you were in a program and had a picture you could use the mail services to attach it to an email. Its very possible these services weren't ready for this beta release...maybe someone with the new beta could check for these services...
 

zpincus

Registered
I found a way that may simulate a restart:
in the terminal, type sudo SystemStarter and then your root password.
And behold, the little boot panel starts up right on top of Aqua.

(Tip: only do this if you pretty comfortable with the terminal and your disk is backed up, etc etc, I don't know for sure that in ten years you won't get cancer because of this...)

SystemStarter, however, does not restart the daemons (check the console.app for its messages), so it still doesn't substitute for a reboot for when you change network settings. (Though there have been scrips made to fix that.) Perhaps, however, the SystemStarter thingie will rescan the services?

I personally don't think it will ever be useful to call SystemStarter from the terminal, but this may be a case. Also, it may be useful if there is a way to force the SystemStarter app to restart the daemons if they're already running.

Zach

[Edited by zpincus on 12-20-2000 at 08:22 PM]
 

monty

Registered
sudo SystemStarter doesn\'t seem to work. Strange seeing the boot panel appear on top of all the apps though. Note: if you want to try it, make sure you su first to log in as root.

peter
 

zpincus

Registered
Originally posted by monty
Quick question why do my \\\'s have a \\\\ before them?
I\\\'m using IE 5 on OSX PB

peter
I think an admin posted something about this a bit ago... IIRC, when macosx.com went to a new server, the backslash problem (and some others) cropped up because the new servers were running older software that does not process the text right.
Tonight or tomorrow they should be getting this fixed (one way or another), if the post was right.

Zach
 
Top