Hi all,

Ben -> the easiest way to kick off some high powered kickarse sharing action
is to get in first. ;-) Here's one of my favourite little unobvious handy
tricks:

Everyone knows the way to start a shell script -> you put in a 'bang path'
to the shell that you want to run your script, like this:

  #!/bin/sh
  echo You ran this script with these parameters:
  echo "  $@"

But what does it actually do? Simple answer: When you execute the script (it
must have the +x bits on), the contents of the file are piped into the bang
path program, in this case, /bin/sh. So, let's put just the last two lines
of the above script into a file ('test'), and try to get sh to run it from
stdin:

  $ cat test | /bin/sh -s
  You ran this script with these parameters:
    
Or:

  $ cat test | /bin/sh -s pants
  You ran this script with these parameters:
    pants

So, why is this cool? It means that *any program* that can take its config
or some kind of scripting from a file can be used this way -> because stdin
is (basically) a file!

Try putting this in a file, and setting the +x bit:

  #!/usr/bin/screen -c
  startup_message on
  hardstatus on
  hardstatus alwayslastline
  hardstatus string "%H %=%{..} %d/%m %C%a "

When you run it, screen will run with that configuration! My normal screenrc
settings have a blue status line, have the startup_message switched off, etc
-> but not when I run this script. :-)

Now... There are a *lot* of *nix command line tools that can take their conf
settings from a file specified on the command line. Such as mutt... vim...
So many cool things you can do, and you can just run a special command and
have them set up for special purposes. :-)

Enjoy, and post the cool stuff you do with this to the SLUG list. :-)

Thanks,

- Jeff

-- 
linux.conf.au 2004: Adelaide, Australia         http://lca2004.linux.org.au/
 
    Echidnas, or at least the ones I've met, don't have joy. Adults very
     rarely have joy. Kids have hyperkinetic nuclear joy in abundance.
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to