Help!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help!!
# 1  
Old 10-25-2005
Help!!

Hi Folks, I have a bit of a problem...

I have a directory with 300+ report files in it.
I need to make a script that will take all these file names and run them within a command.
This is the command i run to produce the report i need:

twprint -m r -r /usr/local/tripwire/tfs/report/x21nwh51-20051009-060024.twr -o /export/home/bgalante/ax21nwh51-1009.html -F html

the x21nwh51-20051009-060024.twr is the report file.

Any help please? I know i prolly need to do a foreach loop, but i suck big at scripting so your help will be greatly appreciated.
Thanks!
# 2  
Old 10-25-2005
#!/bin/sh

# declare variables
RPTDIR="/usr/local/tripwire/tfs/report/"
RPTS=`ls -1 $RPTDIR/*.twr`
RPTOUT="/export/home/bgalante"

# for every report in your report listing array
for rpt in $RPTS
do
# strip first part of the name
# for example x21nwh51-20051009-060024.twr
# would be x21nwh51
rpthtml=`echo $rpt | cut -d- -f1`
# create html from report and make the name unique
# x21nwh51-20051025-15:11:58.html
twprint -m r -r $RPTDIR/$rpt -o $RPTOUT/$rpthtml-`date +%Y%m%d-%H:%M:%S`.html -F html
done
# 3  
Old 10-25-2005
here is what im getting now...

Error: File cannot be opened.
### Filename:
### /usr/local/tripwire/tfs/report///usr/local/tripwire/tfs/report//x21nwh51-20041029-132911.twr
### No such file or directory
### Exiting...


Thanks for helping, im trying to figure this one out, do you know why im getting that error?
# 4  
Old 10-25-2005
Fixed a line...see below

#!/bin/sh

# declare variables
RPTDIR="/usr/local/tripwire/tfs/report"
# Incorrect syntax to get basename of file
# this has been corrected
RPTS=`cd $RPTDIR && ls -1 *.twr`
RPTOUT="/export/home/bgalante"

# for every report in your report listing array
for rpt in $RPTS
do
# strip first part of the name
# for example x21nwh51-20051009-060024.twr
# would be x21nwh51
rpthtml=`echo $rpt | cut -d- -f1`
# create html from report and make the name unique
# x21nwh51-20051025-15:11:58.html
twprint -m r -r $RPTDIR/$rpt -o $RPTOUT/$rpthtml-`date +%Y%m%d-%H:%M:%S`.html -F html
done

Last edited by supaphat; 10-25-2005 at 02:20 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question