<html><body><div style="font-family: Arial; font-size: 12pt; color: #000000"><div aria-label="Compose body">Hi guys,<br></div><div aria-label="Compose body"><br></div><div aria-label="Compose body">&nbsp;&nbsp; I'm trying to write a script to find setuid/setgid files on different servers, &amp; while I think I'm pretty *close* to having it complete, I'm running into one error that I just can't seem to wrap my brain around.&nbsp; To begin with, here's the script (so far):<br></div><div aria-label="Compose body"><br></div><div aria-label="Compose body"><span style="font-family: Consolas; font-size: small;" face="Consolas" size="2" data-mce-style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;" face="Consolas" size="2" data-mce-style="font-family: Consolas; font-size: small;"><span style="font-size: 11pt;" data-mce-style="font-size: 11pt;"></span></span></span><div style="padding-left: 30px;" data-mce-style="padding-left: 30px;"><span style="color: #002060;" color="#002060" data-mce-style="color: #002060;">#!/bin/bash</span></div><span style="font-family: Consolas; font-size: small;" face="Consolas" size="2" data-mce-style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;" face="Consolas" size="2" data-mce-style="font-family: Consolas; font-size: small;"><span style="font-size: 11pt;" data-mce-style="font-size: 11pt;"></span></span></span><div style="padding-left: 30px;" data-mce-style="padding-left: 30px;"><span style="color: #002060;" color="#002060" data-mce-style="color: #002060;">set -x</span></div><span style="font-family: Consolas; font-size: small;" face="Consolas" size="2" data-mce-style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;" face="Consolas" size="2" data-mce-style="font-family: Consolas; font-size: small;"><span style="font-size: 11pt;" data-mce-style="font-size: 11pt;"></span></span></span><div style="padding-left: 30px;" data-mce-style="padding-left: 30px;"><span style="color: #002060;" color="#002060" data-mce-style="color: #002060;">for i in $(`df -hl&nbsp; | awk '{print $NF}' | grep -v ^\/dev`);</span></div><span style="font-family: Consolas; font-size: small;" face="Consolas" size="2" data-mce-style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;" face="Consolas" size="2" data-mce-style="font-family: Consolas; font-size: small;"><span style="font-size: 11pt;" data-mce-style="font-size: 11pt;"></span></span></span><div style="padding-left: 30px;" data-mce-style="padding-left: 30px;"><span style="color: #002060;" color="#002060" data-mce-style="color: #002060;">do</span></div><span style="font-family: Consolas; font-size: small;" face="Consolas" size="2" data-mce-style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;" face="Consolas" size="2" data-mce-style="font-family: Consolas; font-size: small;"><span style="font-size: 11pt;" data-mce-style="font-size: 11pt;"></span></span></span><div style="padding-left: 30px;" data-mce-style="padding-left: 30px;"><span style="color: #002060;" color="#002060" data-mce-style="color: #002060;">#&nbsp; find $i -path /proc -prune -o -type f -perm +6000 -ls &gt;&gt; /tmp/Test1_"$HOSTNAME".txt</span></div><span style="font-family: Consolas; font-size: small;" face="Consolas" size="2" data-mce-style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;" face="Consolas" size="2" data-mce-style="font-family: Consolas; font-size: small;"><span style="font-size: 11pt;" data-mce-style="font-size: 11pt;"></span></span></span><div style="padding-left: 30px;" data-mce-style="padding-left: 30px;"><span style="color: #002060;" color="#002060" data-mce-style="color: #002060;">&nbsp;&nbsp; echo $i| rev ;</span></div><span style="font-family: Consolas; font-size: small;" face="Consolas" size="2" data-mce-style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;" face="Consolas" size="2" data-mce-style="font-family: Consolas; font-size: small;"><span style="font-size: 11pt;" data-mce-style="font-size: 11pt;"></span></span></span><div style="padding-left: 30px;" data-mce-style="padding-left: 30px;"><span style="color: #002060;" color="#002060" data-mce-style="color: #002060;">done</span></div><span style="font-family: Consolas; font-size: small;" face="Consolas" size="2" data-mce-style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;" face="Consolas" size="2" data-mce-style="font-family: Consolas; font-size: small;"><span style="font-size: 11pt;" data-mce-style="font-size: 11pt;"></span></span></span><div><span style="color: #002060; font-family: Calibri;" color="#002060" face="Calibri" data-mce-style="color: #002060; font-family: Calibri;">&nbsp;</span></div><div><span style="color: rgb(0, 0, 0); font-family: arial,helvetica,freesans,sans-serif;" color="#002060" face="Calibri" data-mce-style="color: #000000; font-family: arial,helvetica,freesans,sans-serif;">I'll skip explaining the 1st two lines, since those are (probably) fairly obvious.&nbsp; The third line basically grabs a listing of *local* filesystems <em>(so that I don't waste 'time x # of servers' rescanning common shared mounts)</em> and assigns it (one line/filesystem at a time) to a variable.</span></div><div><span style="color: rgb(0, 0, 0); font-family: arial,helvetica,freesans,sans-serif;" color="#002060" face="Calibri" data-mce-style="color: #000000; font-family: arial,helvetica,freesans,sans-serif;"><br></span></div><div><span style="color: rgb(0, 0, 0); font-family: arial,helvetica,freesans,sans-serif;" color="#002060" face="Calibri" data-mce-style="color: #000000; font-family: arial,helvetica,freesans,sans-serif;">The variable is then used as the target filesystem within a find statement <em>(the intent is to keep from having to manually determine the local filesystems on each of the different servers)</em>.&nbsp; In the script above, that line is commented out because I was trying to determine whether that line was contributing to the problem I'm seeing.&nbsp; The following 'echo' line is just there to provide output to the screen so that I can see what, if anything is being generated.&nbsp; (So far, that line isn't producing anything.)<br></span></div><div><span style="color: rgb(0, 0, 0); font-family: arial,helvetica,freesans,sans-serif;" color="#002060" face="Calibri" data-mce-style="color: #000000; font-family: arial,helvetica,freesans,sans-serif;"><br></span></div><div><span style="color: rgb(0, 0, 0); font-family: arial,helvetica,freesans,sans-serif;" color="#002060" face="Calibri" data-mce-style="color: #000000; font-family: arial,helvetica,freesans,sans-serif;">Prior to adding the 'set -x' line for debugging, the only output that I received was the line '<span style="font-family: Consolas; font-size: small;" face="Consolas" size="2" data-mce-style="font-family: Consolas; font-size: small;"><span style="font-size: 11pt;" data-mce-style="font-size: 11pt;"><span style="color: #1f497d;" color="#1F497D" data-mce-style="color: #1f497d;">forloop.sh: line 7: on: command not found</span></span></span>'.&nbsp; It *seems* apparent that it's somehow extracting the center two characters from the 'done' string in line 7, &amp; trying to use that as a command - but I have no idea how/why it's doing that.<br></span></div><div><span style="color: rgb(0, 0, 0); font-family: arial,helvetica,freesans,sans-serif;" color="#002060" face="Calibri" data-mce-style="color: #000000; font-family: arial,helvetica,freesans,sans-serif;"><br></span></div><div><span style="color: rgb(0, 0, 0); font-family: arial,helvetica,freesans,sans-serif;" color="#002060" face="Calibri" data-mce-style="color: #000000; font-family: arial,helvetica,freesans,sans-serif;">After adding the 'set -x' line to the script, the output becomes:<br></span></div><div><span style="color: rgb(0, 0, 0); font-family: arial,helvetica,freesans,sans-serif;" color="#002060" face="Calibri" data-mce-style="color: #000000; font-family: arial,helvetica,freesans,sans-serif;"><br></span></div><div><div style="padding-left: 30px;"><span style="color: #1f497d;" color="#1F497D" data-mce-style="color: #1f497d;">+++ df -hl</span></div><div style="padding-left: 30px;"><span style="color: #1f497d;" color="#1F497D" data-mce-style="color: #1f497d;">+++ awk '{print $NF}'</span></div><div style="padding-left: 30px;"><span style="color: #1f497d;" color="#1F497D" data-mce-style="color: #1f497d;">+++ grep -v '^/dev'</span></div><div style="padding-left: 30px;"><span style="color: #1f497d;" color="#1F497D" data-mce-style="color: #1f497d;">++ on / /boot /home /opt /var /prod/app/local /prod/app/shared</span></div><div style="padding-left: 30px;"><span style="color: #1f497d;" color="#1F497D" data-mce-style="color: #1f497d;">forloop.sh: line 7: on: command not found</span></div><div><span style="color: #1f497d;" color="#1F497D" data-mce-style="color: #1f497d;"><br></span></div><div><span style="color: #1f497d;" color="#1F497D" data-mce-style="color: #1f497d;"><span style="color: #000000; font-family: arial,helvetica,freesans,sans-serif;" color="#002060" face="Calibri" data-mce-style="color: #000000; font-family: arial,helvetica,freesans,sans-serif;">Is anyone here able to explain why I'm seeing this behavior??&nbsp; Thanks in advance.<br></span></span></div><div><span style="color: #1f497d;" color="#1F497D" data-mce-style="color: #1f497d;"><span style="color: #000000; font-family: arial,helvetica,freesans,sans-serif;" color="#002060" face="Calibri" data-mce-style="color: #000000; font-family: arial,helvetica,freesans,sans-serif;"><br></span></span></div><div><span style="color: #1f497d;" color="#1F497D" data-mce-style="color: #1f497d;"><span style="color: #000000; font-family: arial,helvetica,freesans,sans-serif;" color="#002060" face="Calibri" data-mce-style="color: #000000; font-family: arial,helvetica,freesans,sans-serif;">T.<br></span></span></div></div></div></div></body></html>