Sponsored Content
Full Discussion: Need help creating a script
Top Forums Shell Programming and Scripting Need help creating a script Post 66304 by Just Ice on Saturday 12th of March 2005 10:13:26 AM
Old 03-12-2005
jim's code as written is correct ...

but instead of just snmpget why don't you do a ping with a timeout first so you don't have to wait forever for each ip address ... i've modified jim's code below using a 5 second timeout on ping and taking out the "Timeout:" error ...

Code:
#!/bin/ksh
# assuming snmpget returns non-zero when printer not running snmp
echo "These ip addresses are not running snmp on " `date` > nosnmp.log
while read ipaddr
do
    ping $ipaddr 5 > /dev/null 2>&1
    if [ $? -eq 0 ]
    then   
          snmpget -v 1 -c public $ipaddr sysName.0 2> /dev/null
          if [ $? -ne 0 ]; 
          then 
                echo "$ipaddr" >> nosnmp.log
          fi
     else
          echo "$ipaddr" >> nosnmp.log
     fi 
done < iplist.txt

or else you can simply do ... since an unpingable networked printer is technically off the network functionwise ... (assuming a 2 second ping timeout) ...

Code:
#! /bin/ksh
echo "These ip addresses are unpingable as of [ `date` ]\n" > noping.log
for ipaddr in `< iplist.txt`
do
     ping $ipaddr 2 2> /dev/null
     if [ $? -ne 0 ]
     then
           echo "$ipaddr" >> noping.log
     fi
done

exit 0

 

10 More Discussions You Might Find Interesting

1. Programming

creating a new C script

All right. Heres the deal, I need to know everysingle command or funtion there is to create a new c file (file.c). Heres the catch: I cannot use text editors!!!:mad: I heard of a "gcc" command is that any good?:confused: Thanks..:cool: (2 Replies)
Discussion started by: AbRa-KaDabRa
2 Replies

2. UNIX for Dummies Questions & Answers

creating a script

I am trying to create a application in OSX through UNIX that will run a script to mount an image from a CD-ROM and run the application which it corresponds to, all with double clicking on a icon in OSX. Any thoughts or ideas? -Mad (3 Replies)
Discussion started by: madknowledge
3 Replies

3. Shell Programming and Scripting

(Urgent):Creating flat file using sql script and sqlplus from UNIX Shell Script

Hi, I need help urgently for following issue. Pls help me to resolve this issue. I am calling sql script file(file1.sql) from UNIX Shell Script(script1.ksh) using sql plus and trying to create flat file that contains all records returned from SQL query in SQL script(file1.sql) I given... (6 Replies)
Discussion started by: praka
6 Replies

4. Shell Programming and Scripting

help needed with creating challenging bash script with creating directories

Hi, Can someone help me with creating a bash shell script. I need to create a script that gets a positive number n as an argument. The script must create n directories in the current directory with names like map_1, map_2 etcetera. Each directory must be contained within its predecessor. So... (7 Replies)
Discussion started by: I-1
7 Replies

5. Programming

need help with creating a sh script

Hi everyone I’m not a programmer and my knowledge of scripting is very poor, now I’m stock in a task at work and would really appreciate it if someone could help me out. Here is the problem: 1. I have a file with 9 million entries that look like this : 611424167 610864581 611881523 609585386... (3 Replies)
Discussion started by: hiker1064
3 Replies

6. UNIX for Dummies Questions & Answers

Creating a script

Alright, well I did some more research since I originally posted this thread, and as much as I'd like to delete it, I can't, so I'll just extend my initial question a little. Right now I have 3 scripts: 1#!/bin/bash # script1 - Write all files modfied x days ago find .. -daystart -mtime 0... (2 Replies)
Discussion started by: Aussiemick
2 Replies

7. Shell Programming and Scripting

Need help in creating file restoration script from a backup script.

Hi all i am struggling in creating a restore of env files while doing applications clone. the first file i created for copying the important configurations file which is running perfect now for reverting the changes i mean when i am restoring these files to its original places i have to do... (7 Replies)
Discussion started by: javeedkaleem
7 Replies

8. Shell Programming and Scripting

Creating IN list in PLSQL script dynamically by using shell script

Hi all, I have a PLSQL script which has a IN list where it takes some ids as input. For example SELECT * FROM EMPLOYEE WHERE EMPLOYEE_ID IN (comma separated list ) I want to run this quest inside a shell script but I would like to prepare the IN list dynamically where the employee ids... (1 Reply)
Discussion started by: LoneRanger
1 Replies

9. Shell Programming and Scripting

Help with creating a script

Hi everyone, I am completely new to this forum and I have some questions regarding a script I am writing. I would be happy if anyone could help me with the small and precise script which should include if, then, else, while until, case and select. The scenario is as follows: 1) A user... (3 Replies)
Discussion started by: codenotfound
3 Replies

10. UNIX for Advanced & Expert Users

Creating script in rc.d

Hi, I have created customized scripts to start httpd and postgres (For CentOS 6) in /etc/init.d. However for it to work even after reboot, I have to put the script in /etc/rc.d/rc0.d, rc1.d, etc. # ls -lrt total 60 -rwxr-xr-x 1 root root 20199 Oct 4 2017 rc.sysinit -rwxr-xr-x 1... (6 Replies)
Discussion started by: anaigini45
6 Replies
SYSLOGD(8)						    BSD System Manager's Manual 						SYSLOGD(8)

NAME
syslogd -- log systems messages SYNOPSIS
syslogd [-468ACcdkNnosTuv] [-a allowed_peer] [-b bind_address] [-f config_file] [-l [mode:]path] [-m mark_interval] [-P pid_file] [-p log_socket] DESCRIPTION
The syslogd utility reads and logs messages to the system console, log files, other machines and/or users as specified by its configuration file. The options are as follows: -4 Force syslogd to use IPv4 addresses only. -6 Force syslogd to use IPv6 addresses only. -8 Tells syslogd not to interfere with 8-bit data. Normally syslogd will replace C1 control characters (ISO 8859 and Unicode characters) with their ``M-x'' equivalent. Note, this option does not change the way syslogd alters control characters (see iscntrl(3)). They will always be replaced with their ``^x'' equivalent. -A Ordinarily, syslogd tries to send the message to only one address even if the host has more than one A or AAAA record. If this option is specified, syslogd tries to send the message to all addresses. -a allowed_peer Allow allowed_peer to log to this syslogd using UDP datagrams. Multiple -a options may be specified. The allowed_peer option may be any of the following: ipaddr/masklen[:service] Accept datagrams from ipaddr (in the usual dotted quad notation) with masklen bits being taken into account when doing the address comparison. ipaddr can be also IPv6 address by enclosing the address with '[' and ']'. If specified, service is the name or number of an UDP service (see services(5)) the source packet must belong to. A service of '*' allows packets being sent from any UDP port. The default service is 'syslog'. If ipaddr is IPv4 address, a missing masklen will be substituted by the historic class A or class B netmasks if ipaddr belongs into the address range of class A or B, respectively, or by 24 otherwise. If ipaddr is IPv6 address, a missing masklen will be substituted by 128. domainname[:service] Accept datagrams where the reverse address lookup yields domainname for the sender address. The meaning of service is as explained above. *domainname[:service] Same as before, except that any source host whose name ends in domainname will get permission. The -a options are ignored if the -s option is also specified. -b bind_address[:service] -b :service Bind to a specific address and/or port. The address can be specified as a hostname, and the port as a service name. If an IPv6 address is specified, it should be enclosed with '[' and ']'. The default service is 'syslog'. -C Create log files that do not exist (permission is set to 0600). -c Disable the compression of repeated instances of the same line into a single line of the form ``last message repeated N times'' when the output is a pipe to another program. If specified twice, disable this compression in all cases. -d Put syslogd into debugging mode. This is probably only of use to developers working on syslogd. -f Specify the pathname of an alternate configuration file; the default is /etc/syslog.conf. -k Disable the translation of messages received with facility ``kern'' to facility ``user''. Usually the ``kern'' facility is reserved for messages read directly from /dev/klog. -m Select the number of minutes between ``mark'' messages; the default is 20 minutes. -N Disable binding on UDP sockets. RFC 3164 recommends that outgoing syslogd messages should originate from the privileged port, this option disables the recommended behavior. This option inherits -s. -n Disable dns query for every request. -o Prefix kernel messages with the full kernel boot file as determined by getbootfile(3). Without this, the kernel message prefix is always ``kernel:''. -p Specify the pathname of an alternate log socket to be used instead; the default is /var/run/log. -P Specify an alternative file in which to store the process ID. The default is /var/run/syslog.pid. -S Specify the pathname of an alternate log socket for privileged applications to be used instead; the default is /var/run/logpriv. -l Specify a location where syslogd should place an additional log socket. The primary use for this is to place additional log sockets in /var/run/log of various chroot filespaces. File permissions for socket can be specified in octal representation before socket name, delimited with a colon. Path to socket location must be absolute. -s Operate in secure mode. Do not log messages from remote machines. If specified twice, no network socket will be opened at all, which also disables logging to remote machines. -T Always use the local time and date for messages received from the network, instead of the timestamp field supplied in the message by the remote host. This is useful if some of the originating hosts can't keep time properly or are unable to generate a correct time- stamp. -u Unique priority logging. Only log messages at the specified priority. Without this option, messages at the stated priority or higher are logged. This option changes the default comparison from ``=>'' to ``=''. -v Verbose logging. If specified once, the numeric facility and priority are logged with each locally-written message. If specified more than once, the names of the facility and priority are logged with each locally-written message. The syslogd utility reads its configuration file when it starts up and whenever it receives a hangup signal. For information on the format of the configuration file, see syslog.conf(5). The syslogd utility reads messages from the UNIX domain sockets /var/run/log and /var/run/logpriv, from an Internet domain socket specified in /etc/services, and from the special device /dev/klog (to read kernel messages). The syslogd utility creates its process ID file, by default /var/run/syslog.pid, and stores its process ID there. This can be used to kill or reconfigure syslogd. The message sent to syslogd should consist of a single line. The message can contain a priority code, which should be a preceding decimal number in angle braces, for example, '<5>'. This priority code should map into the priorities defined in the include file <sys/syslog.h>. For security reasons, syslogd will not append to log files that do not exist (unless -C option is specified); therefore, they must be created manually before running syslogd. The date and time are taken from the received message. If the format of the timestamp field is incorrect, time obtained from the local host is used instead. This can be overridden by the -T flag. FILES
/etc/syslog.conf configuration file /var/run/syslog.pid default process ID file /var/run/log name of the UNIX domain datagram log socket /var/run/logpriv UNIX socket for privileged applications /dev/klog kernel log device SEE ALSO
logger(1), syslog(3), services(5), syslog.conf(5), newsyslog(8) HISTORY
The syslogd utility appeared in 4.3BSD. The -a, -s, -u, and -v options are FreeBSD 2.2 extensions. BUGS
The ability to log messages received in UDP packets is equivalent to an unauthenticated remote disk-filling service, and should probably be disabled by default. Some sort of inter-syslogd authentication mechanism ought to be worked out. To prevent the worst abuse, use of the -a option is therefore highly recommended. The -a matching algorithm does not pretend to be very efficient; use of numeric IP addresses is faster than domain name comparison. Since the allowed peer list is being walked linearly, peer groups where frequent messages are being anticipated from should be put early into the -a list. The log socket was moved from /dev to ease the use of a read-only root file system. This may confuse some old binaries so that a symbolic link might be used for a transitional period. BSD
May 13, 2008 BSD
All times are GMT -4. The time now is 03:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy