Sponsored Content
Top Forums Shell Programming and Scripting Help it works but its to SLOW Post 302180780 by Garlandxj on Tuesday 1st of April 2008 06:14:52 AM
Old 04-01-2008
Thank you for the reply. Hopefully with practice I won't have to ask such basic questions.

The thought I have in my head is a count

I have been playing with different ones i have found online and I can't get them to work. I am sure it is me that is the problem.

The only purpose of the first script file is to cat the file device.txt and store the variable $device then export that to the second script file i call as a back ground process.

What I am hoping for but cannot get the syntax correct is

as the first script launches background processes it starts a count of how many it has started. Once it reaches 100 it either waits for all background processes to finish (preferable) then continues on. OR

it sleeps for 120 seconds before firing off the next hundred.


As for the cat the output redirect is inside the script that is called

named devicev2

ip=`(host $device | awk ' /has/ {print $4}')`

if [ "$ip" ]
then
dns="$ip"


answer=`(ping -c 1 -q -w 2 -n $device 2>/dev/null | grep received | awk '{print $4}')`
if
[ $answer = 0 ];
then answer="NO"
else answer="YES"
fi


if
[ $answer = "YES" ];
then

routername=`(snmpget -t 2 -r 0 -Oqv -Os -v 2c -c (Read only community string) $device 2>/dev/null SNMPv2-MIB::sysName.0)`
if [ "$routername" = "" ];
then snmpread="NO"
routername="N/A"
else snmpread="YES"
fi
snmpwrite=`(snmpget -t 2 -r 0 -Oqv -Os -v 2c -c (Read Write community string) $device 2>/dev/null SNMPv2-MIB::sysName.0)`
if [ "$snmpwrite" = "" ];
then snmpwrite="NO"
else snmpwrite="YES"
fi

if [ "$snmpwrite" = "YES" ];
then
devicenumber=`(snmpwalk -v 2c -OQs -c (Read Write community string) $device 1.3.6.1.2.1.4.20.1.2 | grep $ip | awk ' /=/ {print $3}')`
interface=`(snmpwalk -v 2c -OQs -c (Read Write community string) $device 1.3.6.1.2.1.2.2.1.2 | grep -w ifDescr.$devicenumber | awk '/=/ {print $3}')`
else
interface="N/A"
fi

echo "$device,$routername,$dns,$answer,$snmpread,$snmpwrite,$interface" >> device.log
echo "$device,$routername,$dns,$answer,$snmpread,$snmpwrite,$interface"

else
snmpread="NO"
snmpwrite="NO"
interface="N/A"
routername="N/A"
echo "$device,$routername,$dns,$answer,$snmpread,$snmpwrite,$interface" >> device.log
echo "$device,$routername,$dns,$answer,$snmpread,$snmpwrite,$interface"

fi

else
dns="Not in DNS"
answer="NO"
snmpread="NO"
snmpwrite="NO"
interface="N/A"
routername="N/A"
echo "$device,$routername,$dns,$answer,$snmpread,$snmpwrite,$interface" >> device.log
echo "$device,$routername,$dns,$answer,$snmpread,$snmpwrite,$interface"

fi

exit
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

slow ftp

On one of of solaris 7 boxes whenever i telnet or ftp it takes sometime before i get the prompt...any quick ideas where I should look...Thanks (3 Replies)
Discussion started by: suntan
3 Replies

2. Post Here to Contact Site Administrators and Moderators

Slow

The site has gone slow for quite some time... Can you do somethin abt it (2 Replies)
Discussion started by: DPAI
2 Replies

3. SCO

Slow cd response

Hi All We have one SCO Server here and it never gives us any trouble. Until Now!! Well its not earth shattering but we have one user who is complaining of a very slow response time when changing to his Home Directory. Other users who have similar profiles are OK. I have su'd to this user and I can... (0 Replies)
Discussion started by: JohnOB
0 Replies

4. UNIX for Dummies Questions & Answers

scp is slow

All of the sudden scp got really slow ... from 2-3 seconds to 30 seconds. This happened for 5 hours, and then it went back to running fast. Why? If I use the -q qualifier which "Disables the progress meter" could this have any adverse effect? Thanks (1 Reply)
Discussion started by: tomstone_98
1 Replies

5. UNIX for Dummies Questions & Answers

How ls | wc -l works?

ls displays files in tabbed output. Say a directory contains 3 files. ls will list all 3 in one line. So, I expect ls | wc -l to give 1, but it counts the nr of files and gives 3. Can someone explain how this works? (3 Replies)
Discussion started by: krishmaths
3 Replies

6. Programming

how this works?

pls explain me how this works.... DECODE (SUBSTR (field, 1, 1),'''', '''''' || field || '''','''' || field || '''') here field is a column in an oracle table.... (7 Replies)
Discussion started by: vijay_0209
7 Replies

7. UNIX for Dummies Questions & Answers

>./a.pl works, >a.pl - does not

When I try to execute script, I get message: >aa.pl zsh: command not found: aa.pl but >./aa.pl works OK. What to change in environment to force the former way to work? Thank you, Alex Z (4 Replies)
Discussion started by: zzol
4 Replies

8. UNIX for Advanced & Expert Users

How this works?

I have a program............ #include<stdio.h> #include<unistd.h> main() { if(fork == 0) { printf("Hi every body:p!!!!!!!!!!"); } } This program works with out any error. here fork is not a system call. It just act as a variable.But how it works without declaring it? What data type it... (19 Replies)
Discussion started by: carolsanjeevi
19 Replies
DDB(8)							    BSD System Manager's Manual 						    DDB(8)

NAME
ddb -- configure DDB kernel debugger properties SYNOPSIS
ddb capture [-M -core] [-N -system] print ddb capture [-M -core] [-N -system] status ddb script scriptname ddb script scriptname=script ddb scripts ddb unscript scriptname ddb pathname DESCRIPTION
The ddb utility configures certain aspects of the ddb(4) kernel debugger from user space that are not configured at compile-time or easily via sysctl(8) MIB entries. To ease configuration, commands can be put in a file which is processed using ddb as shown in the last synopsis line. An absolute pathname must be used. The file will be read line by line and applied as arguments to the ddb utility. Whitespace at the beginning of lines will be ignored as will lines where the first non-whitespace character is '#'. OUTPUT CAPTURE
The ddb utility can be used to extract the contents of the ddb(4) output capture buffer of the current live kernel, or from the crash dump of a kernel on disk. The following debugger commands are available from the command line: capture [-M core] [-N system] print Print the current contents of the ddb(4) output capture buffer. capture [-M core] [-N system] status Print the current status of the ddb(4) output capture buffer. SCRIPTING
The ddb utility can be used to configure aspects of ddb(4) scripting from user space; scripting support is described in more detail in ddb(4). Each of the debugger commands is available from the command line: script scriptname Print the script named scriptname. script scriptname=script Define a script named scriptname. As many scripts contain characters interpreted in special ways by the shell, it is advisable to enclose script in quotes. scripts List currently defined scripts. unscript scriptname Delete the script named scriptname. EXIT STATUS
The ddb utility exits 0 on success, and >0 if an error occurs. EXAMPLES
The following example defines a script that will execute when the kernel debugger is entered as a result of a break signal: ddb script kdb.enter.break="show pcpu; bt" The following example will delete the script: ddb unscript kdb.enter.break For further examples, see the ddb(4) and textdump(4) manual pages. SEE ALSO
ddb(4), textdump(4), sysctl(8) HISTORY
The ddb utility first appeared in FreeBSD 7.1. AUTHORS
Robert N M Watson BUGS
Ideally, ddb would not exist, as all pertinent aspects of ddb(4) could be configured directly via sysctl(8). BSD
December 24, 2008 BSD
All times are GMT -4. The time now is 01:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy