[clue] Bash baffler
foo7775 at comcast.net
foo7775 at comcast.net
Wed Jun 4 17:08:36 MDT 2014
A couple things that came to mind after I hit 'send':
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.
Next, I wouldn't be too surprised to hear that there are simpler ways of finding setuid/setgid files (i.e., 'find' piped to 'grep -v' to filter out undesired filesystems) , 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 ALSO because I want to learn why this behavior is occurring, and I want to get just a bit better with my shell scripting.
Thanks again guys.
T.
----- Original Message -----
From: foo7775 at comcast.net
To: "list, CLUE" <clue at cluedenver.org>
Sent: Wednesday, June 4, 2014 4:53:54 PM
Subject: [clue] Bash baffler
Hi guys,
I'm trying to write a script to find setuid/setgid files on different servers, & 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. To begin with, here's the script (so far):
#!/bin/bash
set -x
for i in $(`df -hl | awk '{print $NF}' | grep -v ^\/dev`);
do
# find $i -path /proc -prune -o -type f -perm +6000 -ls >> /tmp/Test1_"$HOSTNAME".txt
echo $i| rev ;
done
I'll skip explaining the 1st two lines, since those are (probably) fairly obvious. The third line basically grabs a listing of *local* filesystems (so that I don't waste 'time x # of servers' rescanning common shared mounts) and assigns it (one line/filesystem at a time) to a variable.
The variable is then used as the target filesystem within a find statement (the intent is to keep from having to manually determine the local filesystems on each of the different servers) . 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. The following 'echo' line is just there to provide output to the screen so that I can see what, if anything is being generated. (So far, that line isn't producing anything.)
Prior to adding the 'set -x' line for debugging, the only output that I received was the line ' forloop.sh: line 7: on: command not found '. It *seems* apparent that it's somehow extracting the center two characters from the 'done' string in line 7, & trying to use that as a command - but I have no idea how/why it's doing that.
After adding the 'set -x' line to the script, the output becomes:
+++ df -hl
+++ awk '{print $NF}'
+++ grep -v '^/dev'
++ on / /boot /home /opt /var /prod/app/local /prod/app/shared
forloop.sh: line 7: on: command not found
Is anyone here able to explain why I'm seeing this behavior?? Thanks in advance.
T.
_______________________________________________
clue mailing list: clue at cluedenver.org
For information, account preferences, or to unsubscribe see:
http://cluedenver.org/mailman/listinfo/clue
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cluedenver.org/pipermail/clue/attachments/20140604/22afae69/attachment-0001.html
More information about the clue
mailing list