Adding script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding script
# 1  
Old 06-11-2013
Adding script

I have a script that will run a lint check on all shell and perl scripts that I have in 2 different branches and will report back in a tmp.log file that will show me what works and doesn't.

I am trying to add to it, so that not only will it bring back the log file or errors, but also to improve to give a good/bad result. So that if a script fails it will report back a 1 and tell me there are errors, but if it does have no errors to report a 0 and no errors found.
# 2  
Old 06-11-2013
We probably need to see the script in order to advise on changing it.
# 3  
Old 06-12-2013
#!/bin/ksh
# -*- Mode: Bash; tab-width: 2; indent-tabs-mode: nil -*- vim:sta:et:sw=2:ts=2:syntax=sh

SCRIPT=$(basename "$0")
SCRDIR=$(dirname "$0")
cd $SCRDIR
SCRDIR=$(pwd)
REPORT=/tmp/${SCRIPT}-report-$(date '+%Y%m%d%H%M%S')
ANCHOR=
PLINT=${SCRDIR}/perllint
KLINT=${SCRDIR}/kshlint
if [ ! -x $PLINT ]
then
echo "File not (found|executable): $PLINT"
exit 1
fi
if [ ! -x $KLINT ]
then
echo "File not (found|executable): $PLINT"
exit 1
fi
for d in .. ../.. ../../.. ../../../..
do
if [ -d ${SCRDIR}/${d}/COMMON ]
then
cd ${SCRDIR}/${d}/COMMON/..
ANCHOR=$(pwd)
break
elif [ -d ${SCRDIR}/${d}/common-src ]
then
cd ${SCRDIR}/${d}/common-src/..
ANCHOR=$(pwd)
break
fi
done
if [ -z "$ANCHOR" ]
then
ANCHOR=.
fi
cat /dev/null > $REPORT
echo "searching for scripts in: $ANCHOR" | tee -a $REPORT
for f in $(find $ANCHOR -type f | grep -v "\.svn" | grep -v cfg2html | grep -v attic)
do
case "$f" in
*.txt|*.bak|*~|*.packlist)
continue
;;
esac
HEAD=$(head -1 $f)
KS=$(echo $HEAD | grep ksh)
PS=$(echo $HEAD | grep perl)
LINT=
if [ -n "$PS" ]
then
# FOUND=$(grep '@_\[0\]' $f)
# if [ -n "$FOUND" ]
# then
# sed -i -e 's/@_\[0\]/\$_\[0\]/' $f
# fi
LINT=${SCRDIR}/perllint
elif [ -n "$KS" ]
then
LINT=${SCRDIR}/kshlint
fi
if [ -n "$LINT" ]
then
echo "running $(basename "$LINT") on: $f" | tee -a $REPORT
$LINT $f 2>&1 | tee -a $REPORT
fi
done
echo "See results in: $REPORT"[/CODE]

Last edited by bigbenn; 07-02-2013 at 12:44 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Adding to an array in an external file, and adding elements to it.

I have an array in an external file, "array.txt", which contains: char *testarray={"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"};I want to be able to add an element to this array, and have that element display, whenever I call it, without having to recompile... (29 Replies)
Discussion started by: ignatius
29 Replies

2. Shell Programming and Scripting

Adding a timeout when using sftp in a script?

Hello guys. I need some help. First of all, sorry about my english, that is not my native languaje. I have a bash script in Solaris with the next lines: And the sftp.sh has this: The problem is that sometimes the sftp takes a long of time. I mean, 2 or 3 hours when it should... (12 Replies)
Discussion started by: giolita25
12 Replies

3. Shell Programming and Scripting

Adding a new line to a script

Good Morning, I have a log file on a solaris 9 machine that gets appended this way: printf "\nBlahBlahBlah - $TIME" but it doesn't create a new line. I have to go into the file and split the bottom line up manually. Any ideas why \n isn't doing what I want? (5 Replies)
Discussion started by: Stellaman1977
5 Replies

4. Programming

Python script for adding number

Dear All I am having following python script. def read_output(file): inp=open(file, "r") row=map(lambda x: x.split(), inp.readlines()) line= for r in row: f1, f2, f3, f4, t = r, int(r), r, int(r), float(r) line.append((f1,... (1 Reply)
Discussion started by: bala06
1 Replies

5. Shell Programming and Scripting

Script adding ^M to end of line

I trying to make a simple script to get info from remote servers my problem is the output of this line- SERVER_NAME=`ssh -t $USER@$REMOTESERVER 'hostname'`the output is linux1^M I would like to remove the ^M where is my error? Many Thanks -Steve (1 Reply)
Discussion started by: shoodlum
1 Replies

6. Shell Programming and Scripting

Adding a while loop to my script

I have a script below that goes to the given directory and plays the newest powerpoint presentation via powerpoint viewer and wine. So far it works perfectly but now Id like to add a while statement to essentially run find /ticker/powerpointshare -mmin -1 -type f -iname "*.ppt" and if it finds a... (9 Replies)
Discussion started by: binary-ninja
9 Replies

7. Shell Programming and Scripting

Adding new lines to a file + adding suffix to a pattern

I need some help with adding lines to file and substitute a pattern. Ok I have a file: #cat names.txt name: John Doe stationed: 1 name: Michael Sweets stationed: 41 . . . And would like to change it to: name: John Doe employed permanently stationed: 1-office (7 Replies)
Discussion started by: hemo21
7 Replies

8. Shell Programming and Scripting

Adding New Selections to the existing Script

Hi.... i have two scripts called: "type" & "selecttype". In "type" i have only the name of the products ex.: product1 & product2. Now, i have to ADD product3 which includes sub categories: productA, productB, productC, productD, productE, productF. so my New type script (menu) looks as... (1 Reply)
Discussion started by: Netrock
1 Replies

9. Shell Programming and Scripting

Help with adding logging to a script

I'm pretty new to bash shell scripting and I was wondering how to add some logging to a script?:confused: (2 Replies)
Discussion started by: kp400sf
2 Replies

10. Shell Programming and Scripting

adding delay in script

Hi Expert, I need to run some command 5 times with 5 mins interval whenever one of the application on server hang. Can I use below scripts ? Thanks! ------------- #!/bin/sh command1 sleep 300 command2 sleep 300 command3 sleep 300 command4 sleep 300 command5 sleep 300... (2 Replies)
Discussion started by: skully
2 Replies
Login or Register to Ask a Question