On Sat, March 10, 2007 3:36 am, Ralph Shumaker wrote:

>
> Anyone know of a way to take this:
>
>> du -a | grep \./\.mozilla/.*/lock | sed -e 's/^[0-9]*\s*\.\//rm ~\//'
>> >> ~/remove-mozilla-lock-file
>
> (whose output would be something like "rm
> ~/.mozilla/default/763qpx3h.slt/lock",)
> and turn it into a command that gets executed without having to put it
into a script and executing the script?  Not having to create and
execute a secondary script would reduce the first script file to 4
lines.
>

I know in Tcl.

set x [exec {<your shell script>}]
eval "exec $x"

Replace the pointy brackets and all between with your shell script, and
away it goes. Shebang is:

#!/usr/bin/tclsh

chmod +x # of course

To learn more, come to the sdtclug meeting, Thursday 3/15/07 at the
Mission Valley campus of th UCSD Extension

Mapquest map of meeting location:

 404 Camino Del Rio South
 Ste. 102
 San Diego, CA 92108

 Go to <http://tinyurl.com/ycahxc> for a map.

FOOTNOTE:

Actually it'd be easier to just exec (shell and execute) $x, which you can
do in almost any scripting language, and I'd have to test this to see if
the substitution in $x needed escaping since it has backslashes, so I
don't recommend using this. But I wanted to demonstrate that Tcl is both
reflexive and introspective, so it is a common and ordinary technique to
have a Tcl script build a Tcl script within itself and then execute it
with eval ... self modifying code without the elements of fear and
unpredictability.

-- 
Lan Barnes

SCM Analyst              Linux Guy
Tcl/Tk Enthusiast        Biodiesel Brewer






-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to