script with admin privileges


# You need to give password for USER <USERNAME>

echo "Please Enter the password for USER `tput smso`<USERNAME>`tput rmso`"

su - <USERNAME> -c "sh bin/"



#!/bin/sh +xv

# set +xv
echo "\n\n\nThis is the Program to remove EXTERNAL HARD DISK DRIVES(e.g. USB, HDD, etc.) :\nProgram is : [`tput smso`{ $0 }`tput rmso`] :\n\n"

# echo $* 
# echo $1

cd /media
echo "Current Directory is : [`tput smso`{ `pwd` }`tput rmso`] :"
# pwd

echo -n "\nExisting files in above Directory are : [`tput smso`{ "
echo -n `ls`
echo " }`tput rmso`] :\n\n\n"

for i in `ls`
echo " `tput smso`{ ${i} }`tput rmso`\n\n"

echo "Do you want to delete `tput smso`${i}`tput rmso`"
read ans

# echo ${ans}
ans=`echo ${ans} | tr [:upper:] [:lower:]`
# echo "ANS ${ans} after proper"
echo "ANS :`tput smso` ${ans}`tput rmso`"

# set -xv

if [ "${ans}" = "y" ]
    echo "\nYes:\nI am going to delete Directory : \t `tput smso`{ /media/${i} }`tput rmso`\n\n\n"

##### Add following lines in /etc/sudoers so "sudo /bin/rmdir functions as intended"
##### <USERNAME> ALL=(ALL) NOPASSWD: /bin/rmdir
    sudo /bin/rmdir /media/${i}

sleep 3

echo "Please press Enter"
read Enter
sleep 11

cd -
# pwd



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s