[wplug] scripting question

Poyner, Brandon bpoyner at ccac.edu
Wed Jan 28 10:16:21 EST 2004


While this script may work for Don's purposes, I thought I would chime
in with some warnings.

If there is any concern about security you should never pipe to a shell.
For instance in this case if there happens to be a file named ;reboot;
sitting anywhere in the path the result would be the same as you typing
'blahblah ./;reboot; > ./;reboot;.bar'.  That will execute reboot twice.
If you're superuser, the box is going down.  More could be done if the
awk didn't limit you to the first field with the field separator of
space.  Limiting to the first field also prevents you from using this
script on files with spaces in their name.

Also, you probably want to be careful with with find.  Without
specifying any file types you end up finding the all directories
including './'.  You probably want to add -type f for files only.

Brandon Poyner
Network Engineer II
CCAC - College Office
412-237-3086


-----Original Message-----
From: Vanco, Don [mailto:don.vanco at agilysys.com] 
Sent: Wednesday, January 28, 2004 9:42 AM
To: 'wplug at wplug.org'
Subject: RE: [wplug] scripting question


perfect - thnx
Don
wplug-admin at wplug.org wrote:
>> Hi all -
>> I need to script a file conversion process.  Basically, I have a
>> directory of files that I need to run a command against, and dump
>> the results to a file named the same as the input but with a unique
>> extension. 
>> 
>> e.g.:
>> 
>> blahblah foo1 > foo1.bar
>> blahblah foo2 > foo2.bar
>> lather, rinse, repeat.....
>> 
>> I'm sure I could figger it out using the output of ls and the "for i
>> in" type syntax - but know that there's some scripting talent
>> lurking here.... and I'm a lazy sot (and have a broken cluster to
>> attend to). 
> 
> 
> 	find ./ | awk '{print "blahblah " $1 " > " $1 ".bar"}' | sh

_______________________________________________
wplug mailing list
wplug at wplug.org
http://www.wplug.org/mailman/listinfo/wplug



More information about the wplug mailing list