[PLUG] shell scripting
Lemseffer. Tahar (MSA)
lemseffert at sacsewer.com
Tue Oct 27 17:33:23 UTC 2009
Good morning Robert,
I run the script and I got the list of all my devices in the hosts file.
true && ( set -x
LIST = 'ypcat hosts|| sort | awk '{print $2}''
for Devices in $LIST
do
Errorcount=`snmpget -v1 -c privator $Devices snmpInBadCommunityNames.O
|awk '{print $4}' `
if [ Errorcount >= 0 ]; then
Devices=$Errorcount
echo $Devices
# line added
echo "$sysdate $Devices" >> /tmp/hosthistory.txt
fi
done
) >& output.txt
Actually that will be nice if can somehow find a way to have and variable that hold the last value when I run it again I should compare it to the new value ..if the new value is greater than the old value==> display the $errorcount..if the new value is equal to the old value ==> no display( basically I only wnt to display when the value changed).
Thanks again robert,
T
-----Original Message-----
From: plug-bounces at lists.pdxlinux.org [mailto:plug-bounces at lists.pdxlinux.org] On Behalf Of Robert Citek
Sent: Monday, October 26, 2009 12:28 PM
To: General Linux/UNIX discussion and help,civil and on-topic
Subject: Re: [PLUG] shell scripting
Can you post the output from the script rather than your description
of the output?
That is, can you wrap your script in this and run it:
true && ( set -x
# insert your script here
) >& output.txt
and post the contents of output.txt. Here's what I mean:
true && ( set -x
LIST = 'ypcat hosts|| sort | awk '{print $2}''
for Devices in $LIST
do
Errorcount=`snmpget -v1 -c privator $Devices snmpInBadCommunityNames.O
|awk '{print $4}' `
if [ Errorcount > 0 ]; then
Devices=$Errorcount
echo $Devices
# line added
echo "$sysdate $Devices" >> /tmp/hosthistory.txt
fi
done
) >& output.txt
When I run the above this is was I get for the contents of output.txt:
$ cat output.txt
+ LIST = 'ypcat hosts|| sort | awk {print' '}'
+ /usr/bin/python /usr/lib/command-not-found -- LIST
+ return 127
-bash: LIST: command not found
Regards,
- Robert
On Mon, Oct 26, 2009 at 2:59 PM, Lemseffer. Tahar (MSA)
<lemseffert at sacsewer.com> wrote:
> Yes I have run it manually?
> The results:
> If the community name is incorrect I get:
> Timeout: no response from Device###
> If the community name is true I get:
> Error count :value
>
> That is what I want to implement
>
> Thanks
>
> -----Original Message-----
> From: plug-bounces at lists.pdxlinux.org
> [mailto:plug-bounces at lists.pdxlinux.org] On Behalf Of Robert Citek
> Sent: Monday, October 26, 2009 11:24 AM
> To: General Linux/UNIX discussion and help,civil and on-topic
> Subject: Re: [PLUG] shell scripting
>
> Maybe the shell script isn't the issue.
>
> Have you tried running the snmpget command manually?
>
> Regards,
> - Robert
>
>
> On Mon, Oct 26, 2009 at 1:27 PM, Lemseffer. Tahar (MSA)
> <lemseffert at sacsewer.com> wrote:
>> Great
>> But I want to be able to get an intrusion some how someone is trying
> to
>> get into the device!!!!1
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
> ____________________________________________________________________________
> EMAIL DISCLAIMER:
> This email and any attachments thereto may contain private, confidential, and
> privileged material for the sole use of the intended recipient. Any review,
> copying, or distribution of this email (or any attachments thereto) by other
> than the intended recipient is strictly prohibited.
>
> If you are not the intended recipient, please contact the sender immediately
> and permanently delete the original and any copies of this email and any
> attachments thereto.
> _____________________________________________________________________________
>
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
>
_______________________________________________
PLUG mailing list
PLUG at lists.pdxlinux.org
http://lists.pdxlinux.org/mailman/listinfo/plug
More information about the PLUG
mailing list