lsattr and my script

For discussions about programming, and for programming questions and advice


Moderator: Forum moderators

Post Reply
Trapster
Posts: 141
Joined: Sat Aug 01, 2020 7:44 pm
Has thanked: 1 time
Been thanked: 38 times

lsattr and my script

Post by Trapster »

I have a script I use to lock down different directories on my server.
When I use lsattr, I get these messages in the console.

Code: Select all

lsattr: Inappropriate ioctl for device While reading flags on /sys
lsattr: Inappropriate ioctl for device While reading flags on /proc
lsattr: Operation not supported While reading flags on /mouse

I have googled and cannot find a way to exclude directories with lsattr.

Is there a way I can exclude directories or suppress these messages with some other method?

Here is the full script:

Code: Select all

#! /bin/bash

STAT=$(echo `lsattr / /usr | grep -e ----i | sed -r 's/^.{15}//'`)
#HELP=$(echo -e "Hello,\nThis is\na multiple lines\nmessage" | xmessage -file -)
export PLOCK="
<window title=\"plock \"icon-name=\"gtk-lock\">
<vbox>

<frame Select a Directory>
        <hbox>
      <entry editable=\"true\" accept=\"directory\">
        <variable>DIR1</variable>
      </entry>
      <button>
        <input file stock=\"gtk-open\"></input>
        <variable>FILE_BROWSE_DIRECTORY</variable>
        <action type=\"fileselect\">DIR1</action>
      </button>
  </hbox>
</frame>
<frame>
<hbox>
<text><label>"___"</label></text>
	<button>
	<label>Show Locked Dir's</label>
	<action>gxmessage -center -bg lightblue -name Locked_Directories \""$STAT" \"</action>
	</button>
<text><label>"___"</label></text>
</hbox>
</frame>
<hbox>
    <button>
      <label>LOCK</label>
      <action>chattr -R +i \$DIR1 && gxmessage -center -bg lightblue -name plock \"The Directory \$DIR1 has been LOCKED.\"</action>
	<action>killall gtkdialog3 && plock</action>
	</button>
<text><label>"____________"</label></text>
    <button>
      <label>UNLOCK</label>
      <action>chattr -R -i \$DIR1 && gxmessage -center -bg lightblue -name plock \"The Directory \$DIR1 has been UNLOCKED.\" </action>
	<action> killall gtkdialog3 && plock</action>
	</button>
  </hbox>
<hbox>
<button help>
<action>gxmessage -center -geometry 400x100 -bg lightblue \"This Program uses chattr to Lock or Unlock Directories.\" </action>
 </button>
<text><label>"____________"</label></text>
   <button>
        <input file icon=\"gtk-quit\"></input>
        <label>QUIT</label>
        <action type=\"exit\">EXIT_NOW</action>
      </button>
</hbox>
</vbox>
</window>
"

PLOCK2=`gtkdialog3 --program=PLOCK --center`

if [ "`echo $PLOCK2 | grep EXIT_NOW`" != "" ]; then
  exit 0
fi

unset PLOCK
Post Reply

Return to “Programming”