![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
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! |
| Forum Sponsor | ||
|
|
|
|||
|
#!/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 |
|
|||
|
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? |
|
|||
|
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 10:20 AM. |
|||
| Google The UNIX and Linux Forums |