10-15-2007
Help me clean this up
UNIX amature/novice. I've written a script (it works) that needs to be cleaned up. I'm searching for a way to perform a "go to , perform this then return" section of code. The books I have and searches i"ve done so far do not show me how to do this. I've pasted in the current code below. I've actually cut out about 75% of the actual script to keep it somewhat brief. So what I'm looking for is a way to cut out the numerous FTP and diff lines since those contain the variables.
Thanks in advance.
#!/usr/bin/ksh
# script to compare current system parameters and constants against
# a known good reference file for each stepper.
# Todd Jones - October 2007
cp blank.dat scan.dat;
cp blank.dat sum.dat;
cp blank.dat err.dat;
now=`date '+%D %T'`
echo "Nikon reference file comparison" >> sum.dat;
echo "" >> sum.dat;
echo ${now} >> sum.dat;
echo "" >> sum.dat;
echo "Files compared" >> sum.dat;
echo "Files with differnces are listed in the summary" >> sum.dat;
echo "and the diferences are appended below" >> sum.dat;
echo "" >> sum.dat
# *** open and read the stepper name
while read tool
do
if [ "${tool}" = 'nsr9' ]; then
machID='AD29018'
elif [ "${tool}" = 'nsr10' ]; then
machID='AD29028'
elif [ "${tool}" = 'nsr11' ]; then
machID='AD33005'
elif [ "${tool}" = 'nsr12' ]; then
machID='AD35001'
elif [ "${tool}" = 'nsr13' ]; then
machID='AD37005'
else
echo 'nope'
fi
# system parameter files
direct='mcsvsys.parm'
filename="mac_adjust_230.${machID}"
ftp -i nsr100 <<EOF
get ${tool}\"mcsv\ pass\"::[${direct}]${filename} ${tool}/${filename}.now
quit
EOF
diff ${tool}/${filename}.now ${tool}/${filename}.std >> temp.txt
if [ "$?" = '1' ]; then
echo "${tool} ${direct} ${filename} differences exist" >> sum.dat
echo "${tool} ${direct} ${filename}" >> scan.dat
echo "" >>scan.dat
temp.txt >> scan.dat
echo "###############################" >> scan.dat
echo "" >> scan.dat
else
echo "${tool} ${direct} ${filename}" >> sum.dat
fi
filename="sys_param_230.${machID}"
ftp -i nsr100 <<EOF
get ${tool}\"mcsv\ pass\"::[${direct}]${filename} ${tool}/${filename}.now
quit
EOF
diff ${tool}/${filename}.now ${tool}/${filename}.std >> temp.txt
if [ "$?" = '1' ]; then
echo "${tool} ${direct} ${filename} differences exist" >> sum.dat
echo "${tool} ${direct} ${filename}" >> scan.dat
echo "" >>scan.dat
temp.txt >> scan.dat
echo "###############################" >> scan.dat
echo "" >> scan.dat
else
echo "${tool} ${direct} ${filename}" >> sum.dat
fi
filename='ilm_param.ilch'
ftp -i nsr100 <<EOF
get ${tool}\"mcsv\ pass\"::[${direct}]${filename} ${tool}/${filename}.now
quit
EOF
diff ${tool}/${filename}.now ${tool}/${filename}.std >> temp.txt
if [ "$?" = '1' ]; then
echo "${tool} ${direct} ${filename} differences exist" >> sum.dat
echo "${tool} ${direct} ${filename}" >> scan.dat
echo "" >>scan.dat
temp.txt >> scan.dat
echo "###############################" >> scan.dat
echo "" >> scan.dat
else
echo "${tool} ${direct} ${filename}" >> sum.dat
fi
filename='multi_af_parameter.mpaf'
ftp -i nsr100 <<EOF
get ${tool}\"mcsv\ pass\"::[${direct}]${filename} ${tool}/${filename}.now
quit
EOF
diff ${tool}/${filename}.now ${tool}/${filename}.std >> temp.txt
if [ "$?" = '1' ]; then
echo "${tool} ${direct} ${filename} differences exist" >> sum.dat
echo "${tool} ${direct} ${filename}" >> scan.dat
echo "" >>scan.dat
temp.txt >> scan.dat
echo "###############################" >> scan.dat
echo "" >> scan.dat
else
echo "${tool} ${direct} ${filename}" >> sum.dat
fi
# *** close list to read stepper
done < nsrlist
scan.dat >> sum.dat
9 More Discussions You Might Find Interesting
1. AIX
I want to write a script in ksh that will delete file that are more than 2 weeks old. (4 Replies)
Discussion started by: jango
4 Replies
2. UNIX for Advanced & Expert Users
I recently had a disk crash and was not able to clean the dump lv off the disk. Now trying to create new lvdump I am running into errors.
My question is how do I remove the old lv out of the ODM? I have tried going through smit and also just rmlv and it cannot find the lv. Yet when I run lslv on... (0 Replies)
Discussion started by: Wamland
0 Replies
3. Shell Programming and Scripting
I have a script which would monitor a given directory and delete any files which are older than 10 days. I was going to set the 10 crob jobs to perform this operation for 10 different directories (some are actually sub-directories), but my boss doesn't like that idea, so I need to do that in one... (1 Reply)
Discussion started by: mpang_
1 Replies
4. UNIX for Advanced & Expert Users
BeginDate 07/01/06
End: 07/31/06
Cust: A02991 - Burnham
0002000 5,829,773 145.3
0009701 4,043,850 267.3
2005000 286,785.13 100.0
BeginDate 07/01/06
End: 07/31/06
Cust: A01239 - East Track PSE
Index A
0009902 317,356.82 890.2
0020021 ... (5 Replies)
Discussion started by: kris01752
5 Replies
5. Shell Programming and Scripting
hi all,
i need to write a script. it should be able to clean the /etc/hosts file like this:
first field is the ip (what else ;))
second field is the fqdn (full qualified domain name)
third field is the hostname
the fourth to n'th field is the rest.
i hope you understand what is needed?... (5 Replies)
Discussion started by: DukeNuke2
5 Replies
6. AIX
When I run command:
>chdev -l hdisk1 -a pv=clear
It shows
Method error (/etc/methods/chgdisk):
0514-062 Cannot perform the requested function because the
specified device is busy.
run:
#>fuser -kxuc /dev/raw1
/dev/raw1:
How to clean PV id? (4 Replies)
Discussion started by: rainbow_bean
4 Replies
7. Shell Programming and Scripting
Hello guys,
this script partially works but it's still pretty ugly and, moreover, if the month is jan/feb/mar... it doesn't work at all.
Could anyone say me how to correct, cut and clean a little bit?
#!/usr/bin/ksh
egrep -v -e "^\s*#" /file/permission | awk '{ print $1 }' | sort | uniq... (3 Replies)
Discussion started by: gogol_bordello
3 Replies
8. UNIX for Advanced & Expert Users
Hi
i have a perl script that i use to clean up empty folders on our server.
I need to make a amendment to this to exclude certain folders. Folders are invisible to end users but must not be cleaned up by this script.
folders i need protecting have unique names
.Highres
.HighresF
.Lowres... (0 Replies)
Discussion started by: treds
0 Replies
9. Shell Programming and Scripting
Hi
I just want to clean up the space in UNIX. Is there any special command that does this process or do I need to manually type the following
rm <filename>
Any help would be really appreciated. Thanks (2 Replies)
Discussion started by: bobby1015
2 Replies