<html><body><div style="font-family: Arial; font-size: 12pt; color: #000000"><div>A couple things that came to mind after I hit 'send':<br></div><div><br></div><div>First, I will be eliminating the part of the find command that prunes the /proc filesystem, since I realize that really isn't doing anything anyway.<br></div><div><br></div><div>Next, I wouldn't be too surprised to hear that there are simpler ways of finding setuid/setgid files <em>(i.e., 'find' piped to 'grep -v' to filter out undesired filesystems)</em>, but I want to do it this way - primarily because I don't want to waste time scanning filesystems whose output is then discarded - but <em>ALSO</em> because I want to learn why this behavior is occurring, and I want to get just a bit better with my shell scripting.<br></div><div><br></div><div>Thanks again guys.<br></div><div><br></div><div>T.<br></div><div><br></div><hr id="zwchr"><div style="color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>foo7775@comcast.net<br><b>To: </b>"list, CLUE" &lt;clue@cluedenver.org&gt;<br><b>Sent: </b>Wednesday, June 4, 2014 4:53:54 PM<br><b>Subject: </b>[clue] Bash baffler<br><div><br></div><div style="font-family: Arial; font-size: 12pt; color: #000000"><div>Hi guys,<br></div><div><br></div><div>&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><br></div><div><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"><span style="font-size: 11pt;"></span></span></span><div style="padding-left: 30px;"><span style="color: #002060;">#!/bin/bash</span></div><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"><span style="font-size: 11pt;"></span></span></span><div style="padding-left: 30px;"><span style="color: #002060;">set -x</span></div><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"><span style="font-size: 11pt;"></span></span></span><div style="padding-left: 30px;"><span 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;"><span style="font-family: Consolas; font-size: small;"><span style="font-size: 11pt;"></span></span></span><div style="padding-left: 30px;"><span style="color: #002060;">do</span></div><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"><span style="font-size: 11pt;"></span></span></span><div style="padding-left: 30px;"><span 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;"><span style="font-family: Consolas; font-size: small;"><span style="font-size: 11pt;"></span></span></span><div style="padding-left: 30px;"><span style="color: #002060;">&nbsp;&nbsp; echo $i| rev ;</span></div><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"><span style="font-size: 11pt;"></span></span></span><div style="padding-left: 30px;"><span style="color: #002060;">done</span></div><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"><span style="font-size: 11pt;"></span></span></span><div><span style="color: #002060; font-family: Calibri;">&nbsp;</span></div><div><span style="color: rgb(0, 0, 0); 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;"><br></span></div><div><span style="color: rgb(0, 0, 0); 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;"><br></span></div><div><span style="color: rgb(0, 0, 0); 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;"><span style="font-size: 11pt;"><span 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;"><br></span></div><div><span style="color: rgb(0, 0, 0); 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;"><br></span></div><div><div style="padding-left: 30px;"><span style="color: #1f497d;">+++ df -hl</span></div><div style="padding-left: 30px;"><span style="color: #1f497d;">+++ awk '{print $NF}'</span></div><div style="padding-left: 30px;"><span style="color: #1f497d;">+++ grep -v '^/dev'</span></div><div style="padding-left: 30px;"><span 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;">forloop.sh: line 7: on: command not found</span></div><div><span style="color: #1f497d;"><br></span></div><div><span style="color: #1f497d;"><span 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;"><span style="color: #000000; font-family: arial,helvetica,freesans,sans-serif;"><br></span></span></div><div><span style="color: #1f497d;"><span style="color: #000000; font-family: arial,helvetica,freesans,sans-serif;">T.<br></span></span></div></div></div></div><br>_______________________________________________<br>clue mailing list: clue@cluedenver.org<br>For information, account preferences, or to unsubscribe see:<br>http://cluedenver.org/mailman/listinfo/clue</div><div><br></div></div></body></html>