Help with hp configuration script (ksh)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with hp configuration script (ksh)
# 8  
Old 01-18-2010
Solved part of it

Itis still not deleting the line from the file but is working through the if statement correctly.

This is what the latest code extract looked like;

Code:
#!/usr/bin/ksh
# Testing the ndd update
 
function test_ndd {
count=0
cd /tmp/PCI
cp /tmp/PCI/nddentries /tmp/PCI/nddentries-temp
for ndd1 in $(<nddentries) ; do
  if grep -c "$ndd1" /tmp/nddconf
  then
    #Catch the line from the grep and shrink it to the first character
    typeset -L1 nddname=`grep "$ndd1" /tmp/nddconf `
    #Check the first char isn't a # and therefore a comment
    if [[ $nddname  = +([A-Z]) ]]
    then
      sed -e "/$ndd1/d" /tmp/PCI/nddentries-temp
      echo "found deleting"
    else
      echo "it was a comment only"
    fi
  else
    echo " needs adding - so leave on the list"
  fi
done
for ndd2 in $(<nddentries)
  do
    trname=`awk -F: '{if ($2 == VAR) print $1}' \ 
      VAR="$ndd2" /tmp/PCI/nddconfupd`
    ndname=`awk -F: '{if ($2 == VAR) print $2}' \
      VAR="$ndd2" /tmp/PCI/nddconfupd`
    ndvalu=`awk -F: '{if ($2 == VAR) print $3}' \
      VAR="$ndd2" /tmp/PCI/nddconfupd`
    echo "# Added for PCI Compliance" >> /tmp/nddconf
    echo "TRANSPORT_NAME[$count]=$trname" >> /tmp/nddconf
    echo "NDD_NAME[$count]=$ndname" >> /tmp/nddconf
    echo "NDD_VALUE[$count]=$ndvalu" >> /tmp/nddconf
    (( count+=1 ))
  done
}
cp /tmp/PCI/nddentries-temp /tmp/PCI/nddentries
rm -f /tmp/PCI/nddentries-temp 
test_ndd

# 9  
Old 01-18-2010
In HP-UX each parameter in /etc/rc.config.d/nddconf consists of three lines. Just deleting one of thse line will invalidate the file. There are also commented-out examples.
Can you post a sample nddconf file?
# 10  
Old 01-18-2010
Hi
Methyl
I am trying to delete lines in list of nddnames that exist in the nddconf file so that I don't try to add them again.
Code:
sed -e 's/'$ndd1'//' -e '/^$/d' nddentries

I have found that my sed command is working but the file is being reset which is why I am not getting the results that I need. How can I change the file and stop it getting overwritten?
Code:
sed -e 's/'$ndd1'//' -e '/^$/d' nddentries > nddentries-temp
cp nddentries-temp nddentries

seems a bit heavy handed but I think that it works - off to test it.....
# 11  
Old 01-18-2010
Quote:
sed -e "/$ndd1/d" /tmp/PCI/nddentries-temp
This line does not do an in situ update. You do indeed need to redirect the output.

If you actually just need to remove all existing entries from nddconf there are easier ways.

It this HP-UX or another operating system?
# 12  
Old 01-18-2010
Hi Methyl
No I am not trying to delete real entries in the nddconf file just compare it with a text file, make a note of anything that hasn't been entered and then add it.
Yes its HPUX
# 13  
Old 01-18-2010
Hi Korg, I was a bit careless when entering my earlier post, perhaps you care to have a look if it is usable now..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Expect script to save configuration from a router

Hy guys, My name is Alex, i am new here and I hope to find some answers. I am trying to run a expect script to telnet to a mikrotik router, run a command (export), and save the output of that commant to a file (outputfile.txt). The problem is that only part of the output is saved to... (2 Replies)
Discussion started by: axexandru
2 Replies

2. Shell Programming and Scripting

Script/SQL configuration

i have a field in a record which is varchar2(180) and i have stored 180 characters in it when i query record for the value from sqldeveloper, it is coming properly when i connect from UNIX and try to query the field, i am getting in 3 lines instead of displaying in 1 line SHELL SCRIPT : sqlplus... (3 Replies)
Discussion started by: vkca
3 Replies

3. Shell Programming and Scripting

configuration for ftp script in main script

Hi, I am new to shell scripting,and i was planning to write a script that will FTP files to destination folder. I was planning that All configuration should be done through a properties files. and finally the output should be Files are transferred I have developed a properties file named... (4 Replies)
Discussion started by: rahul125
4 Replies

4. Shell Programming and Scripting

KSH script to run other ksh scripts and output it to a file and/or email

Hi I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email. For example ------- Script ABC ------- a.ksh b.ksh c.ksh I need to call all three scripts execute them and... (2 Replies)
Discussion started by: pacifican
2 Replies

5. UNIX for Advanced & Expert Users

Script to get system configuration

Hi, We have >1000 UNIX boxes in our environment with various UNIX flavors like Solaris, HP-UX and Redhat Linux ES 3/4/5. We need to collect their system configuration like - No. of CPUs and their frequencies - RAM Size - No. of HDDs installed and their usage - Exact OS Version and its... (3 Replies)
Discussion started by: prvnrk
3 Replies

6. Shell Programming and Scripting

Match configuration files with a script

Hi all, Can you help me make a script(ksh-Solaris 8) that will match two configuration files? I have some problems with sed newline. The script should at least match the value of parameters from one file to another, which looks always like this: parameter1=some_value... (3 Replies)
Discussion started by: majormark
3 Replies

7. Shell Programming and Scripting

import var and function from ksh script to another ksh script

Ih all, i have multiples ksh scripts for crontab's unix jobs they all have same variables declarations and some similar functions i would have a only single script file to declare my variables, like: var1= "aaa" var2= "bbb" var3= "ccc" ... function ab { ...} function bc { ... }... (2 Replies)
Discussion started by: wolfhurt
2 Replies

8. Shell Programming and Scripting

tracing a ksh script within a ksh script

I normally trace a script with the ksh -x <script name> and redirect strderr to file. But if you have a script like the examble below...... vi hairy bear=`grep bear animals` if then ksh more_animals fi If I ksh -x hairy it won't trace "more_animals" unless I put a -x in it. Is... (1 Reply)
Discussion started by: shorty
1 Replies

9. Shell Programming and Scripting

executing a ksh script from another ksh script

Hi, I'm new to unix scripting.How can i call a script from another script. I have a.ksh and b.ksh .I have to call b.ksh from a.ksh after it is successfully exceuted. I tried using #!/bin/ksh -x in a.ksh and at the end i have used /path/b.ksh My problem is it is executing only a.ksh.it... (6 Replies)
Discussion started by: ammu
6 Replies

10. Shell Programming and Scripting

script to read configuration file

Hi, I would like to write a Korn shell script which will remove files older than a certain date. In my script, it will read a configuration file with the following entries: # <directory> <filename wildcard> # /home/philip/log *.log /home/philip/log1 delete-me*.log The... (1 Reply)
Discussion started by: philip_dba
1 Replies
Login or Register to Ask a Question