[PLUG] shell scripting

Robert Citek robert.citek at gmail.com
Mon Oct 26 16:57:22 UTC 2009


Try running this variation of the script:

LIST = 'ypcat hosts|| sort | awk '{print $2}''
for Devices in $LIST ; do
  echo $Devices
done > output.txt

Post the contents of output.txt

I suspect the error is in using single quotes instead of backtics and
possibly using an OR (||) instead of a pipe.  If you are using bash, I
would recommend using $() instead of backtics.

Regards,
- Robert


On Wed, Oct 21, 2009 at 5:00 PM, Lemseffer. Tahar  (MSA)
<lemseffert at sacsewer.com> wrote:
> here is what i did :
>
> 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
>
> but the answer is wrong cause i'm getting an errorcount.
>
> Thank you All
>
>
> -----Original Message-----
> From: plug-bounces at lists.pdxlinux.org
> [mailto:plug-bounces at lists.pdxlinux.org] On Behalf Of jgw at freeshell.org
> Sent: Wednesday, October 21, 2009 12:30 PM
> To: plug at lists.pdxlinux.org
> Subject: Re: [PLUG] PLUG AT talk this Thursday?
>
> Michael Dexter wrote:
>
>> > Michael> What are people's thoughts about a NetBSD Xen walk through
> on
>> > Michael> Thursday from 7PM - 9PM at Club 915 at 915 SW 2nd?
>> > ...
>>
>> Would anyone want THIS topic THIS Thursday?
>
> I would.  Is this still happening?
>
> Jeff W
> _______________________________________________
> 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
>



More information about the PLUG mailing list