Using Quicksilver to run a shell script in the current Terminal window.
-
Quicksilver / OS X shell junkies: How can I have Quicksilver run a shell script in the current (or a particular) terminal window? Alternately, how can I pipe the output of the script to a particular terminal window? I have a script which I need to run 100+ times a day, and occasionally scan the (often quite long) output. The two QS options for running scripts are to "Run...", which puts the output in the Quicksilver pane -- unhelpful, because then I can't scan the results -- or "Run in Terminal", which opens a new window -- unhelpful, because then I eventually have to close the 30 or so terminal windows that get spawned. Any advice? I guess I could do something like pipe the output of the script to a file and then tail -f that file in a separate window, but I'd also like to know if there's a Quicksilver solution.
-
Answer:
It could be that cvs is outputting to stderr. Command line programs can output to stdout and stderr. Generally, stdout is used for normal output, and stderr is used for error messages. The idea being that a program's normal output can be captured without being tarnished by diagnostic messages. If you're using bash, try the following, it will send both stdout and stderr to the file: ScriptName.sh > log.txt 2>&1
tweebiscuit at Ask.Metafilter.Com Visit the source
Other answers
What the script does, in a nutshell -- commits a bunch of files to CVS (first checking for updates), ssh's to the dev box, updates the files from CVS, and runs a build script (on the dev box still). I need to scan the output to see if any files were updated locally, as well as to see if there were any build errors.
tweebiscuit
I think you ought to be able to write an Applescript that can access the correct window, and then call THAT with Quicksilver.
mkultra
Yeah, on further looking, Terminal exposes a boolean "frontmost" property of its window class. So, I haven't touched AS in years, but your script will loosely look like.. tell Application "Terminal" for every window if thiswindow.frontmost is "yes" execute script "blah blah blah" end end end
mkultra
Hmm... AppleScript seems a little bit roundabout, but I guess I could try it as a last resort. I experimented using "ScriptName.sh > log.txt" and tail -f'ing that file, but not all the output that appears in the terminal window ended up in the file -- in fact, only the output of the remote build script did, and none of the CVS command output. Is there an output-piping technique I'm ignorant of here? (I certainly wouldn't doubt it -- I'm still quite new to the CLI -- the script I'm trying to get the output of is both the first and last shell script I've written.)
tweebiscuit
Not to be dense here, but why is Quicksilver involved? I don't use a mac, so maybe it's obvious, but if you have a shell script, why aren't you just running it directly in the terminal window? That wouldn't spawn any new windows. And if you're leaving the terminal window open all day, it's just a matter of "up arrow, enter" to re-run it. As for your redirected output not showing up, you probably need to look into http://textsnippets.com/posts/show/63.
team lowkey
I use Quicksilver just because it's a lot faster, especially since I usually have multiple terminal windows open, but only one that I can run the script in, and don't spend all that much time in terminal, so it's the difference between "command-tab, command-tab some more until I find terminal, command-tilde, command-tilde, oops another command-tilde, up-arrow, enter" and "command-space, two-letter abbreviation for script, enter" -- i.e., the difference between five seconds and less than one. :) And thanks, mjp, that line did indeed send all the output I needed to the file. Thanks! Still hoping for the Quicksilver answer, though -- any way to run a script (or an arbitrary text command) in the current or a particular terminal window?
tweebiscuit
Is it just a single, unchanging command you're kicking off? Why not use something like shadowClipboard, which stores multiple clips as well as some permanent ones you can call with a keystroke.
mkultra
Open http://protoplasmic.org/code/apple/Run%20in%20frontmost%20terminal.applescript in Script editor and save it (as a script, not text) to ~/Library/Application Support/Quicksilver/Actions/. Make sure the process text plugin is installed and restart Quicksilver (Ctrl-Apple-Q). You then should be able to do "text" -> run in frontmost terminal or run in frontmost -> process text -> "text". Quicksilver process text script looks like this: using terms from application "Quicksilver"    on process text theString       -- do stuff    end process text end using terms from
easyasy3k
Thank easasy3k! I'd still like to be able to run a particular SCRIPT in a particular window, but this will do in a pinch. I appreciate it!
tweebiscuit
Related Q & A:
- How come CD doesn't work in my shell script?Best solution by Super User
- How to call shell script into perl?Best solution by Stack Overflow
- How to load a Java web app in the terminal?Best solution by stackoverflow.com
- How to execute Unix shell script from Windows?Best solution by Stack Overflow
- how can I write this shell script in python?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.