- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- unable to invoke under name userdel.org error
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2004 10:52 PM
05-24-2004 10:52 PM
I am trying to write one shell script which will delete users as well as it will delete from ftpusers entry and cron.allow entry and remove from cron.
But i am getting two problem. One and the main problem is userdel itself.
I have move /usr/sbin/userdel as /usr/sbin/userdel.org and i am invoking that userdel.org from userdel script which i kept in /usr/sbin directory.
When running /usr/sbin/userdel script i am getting below error message:
"Unable to invoke under name 'userdel.org' "
Please assist how to overcome this and what is the reason behind this.
Also if the above problem solve then one more problem exist. On that script how do i invoke userdel -r option?
Attached is my script.
Any help or suggestion is highly appreciated.
Regards
Tapas
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2004 11:10 PM
05-24-2004 11:10 PM
Re: unable to invoke under name userdel.org error
I should imagine that this is done for security reasons. Certainly someone has gone to the trouble of detecting that it has been renamed and reporting that!
regards,
Darren.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2004 11:24 PM
05-24-2004 11:24 PM
Re: unable to invoke under name userdel.org error
You cannot use userdel if you change its name.
manish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2004 11:36 PM
05-24-2004 11:36 PM
Re: unable to invoke under name userdel.org error
Also, can you tell me how to include -r option in my script? Below(attached) is my script. Please specify where to change.
Rgds
Tapas
#!/usr/bin/sh
Usage() {
echo "\nUsage: $1 [-r]
echo "-r: To remove the home directory user this option\n"
exit
}
deletelogin() {
login=$1
echo "deleting User ${login}" >> $USR_DEL_LOG
/usr/sbin/userdel.org $login
}
if [ $# -lt 1 ]
then
Usage $0
fi
until [ -z "$1" ]
do
deletelogin $1
shift
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2004 11:55 PM
05-24-2004 11:55 PM
Re: unable to invoke under name userdel.org error
ls -li /usr/bin/w /usr/bin/uptime
Another well-known set of commands are the dos and ls family. dosls, dosmkdir, dosll, dosrm, etc are links (8) and ls, ll, lsf, lsr, etc are also links (7).
There is no workaround since the program checks it's runtime name $0 when it starts. You'll have to rename userdel.org back to userdel and rename your script to deluser or something similar. Since userdel will not allow non-root user to run it, there doesn't seem to be much point in renaming the command. If your script is performing additional deletion steps, you can use SAM's task customization to accomplish these tasks.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2004 12:04 AM
05-25-2004 12:04 AM
Solution/usr/sbin/userdel -r $login
Since this type of script requires root privileges to run, I would definitely rename the script to something like deluser and place it into a local root directory so you'll remember where it is. A lot of root-only tools get created by sysadmins and then are forgotten when installing or upgrading. root's $HOME is always /root and I use /root/bin for these specialized scripts.
Another technique is to lockout non-root user at the front of the script:
if [ $(id -u) -ne 0 ]
then
echo "\nRequires root to run\n"
exit 1
fi
You may want to takewaway the root password from most of your helpers and instead, give them sudo to run these special commands. The advantage with sudo is that you can prevent users from even attempting to run certain commands (like userdel) but allow them to run a command (script) like yours. And all sudo runs, successful or not, will be logged.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2004 12:38 AM
05-25-2004 12:38 AM
Re: unable to invoke under name userdel.org error
Thanks for your beutiful reply. I think your point is right.
I have moved original userdel to /usr/local/bin and place my userdel
script to /usr/sbin. This solves the problem.
Regarding -r option : In my script you can put several users name.
Like ::: userdel test1 test2 test3 . It will delete all users as well as it will delete from ftpusers and cron file. (test1, test2 test3 are loginname)
My question was if i use : userdel -r test1 test2 test3 Then how do i parse -r?
In my script main program is calling deletelogin $1 (in deletelogin it is like: /usr/local/bin/userdel login. I don't want to put -r here) and after that shift is changing $1.
Rgds
Tapas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2004 03:23 AM
05-25-2004 03:23 AM
Re: unable to invoke under name userdel.org error
userdel -r test1 -r test2 test3 -r test4
So your script would look more like this (I have added validation code for users, tests to prevent removing root users and a different way to count the runtime parameters at the bottom):
#!/usr/bin/sh
set -u
export PATH=/usr/bin
USR_DEL_LOG=/var/tmp/userdel.log
function Usage
{
echo "\nUsage: $1 [-r]
echo "-r: To remove the home directory user this option\n"
exit
}
function Deletelogin
{
OPTION="$1"
LOGIN=$2
if [ $(logins -l $LOGIN | awk '{print $1}') != $LOGIN ]
then
echo "\nUser $LOGIN not found - ignored"
elif [ $(id -u $LOGIN) -eq 0 ]
then
echo "\nUser $LOGIN is superuser - ignored"
else
echo "deleting User ${LOGIN}" >> $USR_DEL_LOG
/usr/sbin/userdel "$MINUSR" $LOGIN
fi
}
# check usage
if [ $# -lt 1 ]
then
Usage $0
fi
# Check if -r was specified
MINUSR=""
if [ "$1" = "-r" ]
then
MINUSR="-r"
shift
fi
COUNT=$#
# loop for all user logins on the line
until [ $# -lt 1 ]
do
Deletelogin "$MINUSR" $1
shift
done
Bill Hassell, sysadmin