![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| clean /etc/hosts | DukeNuke2 | Shell Programming and Scripting | 5 | 11-07-2006 01:42 AM |
| Clean File | kris01752 | UNIX for Advanced & Expert Users | 5 | 09-28-2006 07:40 AM |
| clean up script | mpang_ | Shell Programming and Scripting | 1 | 07-17-2006 08:14 PM |
| Clean an LV out of the ODM | Wamland | UNIX for Advanced & Expert Users | 0 | 11-23-2004 12:44 PM |
| Directory clean up | jango | AIX | 4 | 08-25-2004 06:00 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
|||
|
sounds like you're looking for a function, you can find plenty of references on how to do this, basically:
function DoSomething { put in your ftp and diff commands } functions are defined before the main part of the program. variables are for the most part global, so you don't really need to worry about sending them to the function or returning them. PS: while read tool do if [ "${tool}" = 'nsr9' ]; then You should really replace this large if/elif with a case statement. |
|||
| Google The UNIX and Linux Forums |