Sponsored Content
Homework and Emergencies Homework & Coursework Questions Script to delete multiple users Post 302895198 by Scrutinizer on Saturday 29th of March 2014 09:10:42 AM
Old 03-29-2014
Hi, it seems unlikely that the first script worked fine, since a dollar-sign is missing before the variable status, the groups are attempted to be created anew for every line of the input file (so that should be done outside the loop) and the header of the input file should be skipped. Also, there should be double quotes around all variable references, for example: "$firstname$surname", plus what happens when a users first name or surname contains a space in it.. . Proper syntax requires a single = sign inside [ ... ] not ==


As to the second part. Check the syntax in the man page of the userdel command.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need a script to delete multiple files

Hello, I am working with about 500,000 text files and 90% of them are duplicates. I need a way to delete the duplicate ones. The files are email messages with the following file name examples: 20040129-1457 This is the Subject line.txt 20040129-1457 This is the Subject line-1.txt... (3 Replies)
Discussion started by: navycow
3 Replies

2. Shell Programming and Scripting

Script to delete all data from multiple files

its urgent!!!!!!111 i need a script which can delete data from multiple files. plz if anybody knows the script plz write a mail to me : (Email addresses are not allowed) (5 Replies)
Discussion started by: uni_ajay_r
5 Replies

3. Shell Programming and Scripting

Need Script to delete multiple entries from a file

I am new to Linux and would appreciate some help. I need a script to do the following: My file contains the following entries more file 1 1 1 1 2 2 2 I want to delete multiple entries of 1 and 2 and just keep one of each. The output should look like more file 1 2 Thanks (1 Reply)
Discussion started by: sidewayz
1 Replies

4. Shell Programming and Scripting

Using userdel -r in a script? To delete multiple users.

I'm getting ready to upgrade to Solaris 10 (from 8) and I'm trying to write a script that will delete approximately 800 user accounts that are no longer required. I'm trying to use the userdel -r command and read the input from a file with the list of user names. I've never been very good at... (3 Replies)
Discussion started by: sol10admin
3 Replies

5. Shell Programming and Scripting

script to delete multiple files in remote machine

Requirement Several files in remote machines ought to be deleted via sh. Name of the files to be deleted are know Approach 1) script was written with ftp (requires credential) and delete command. File names were passed as array(iterated via for loop-with ftp+delete commands enclosed within... (1 Reply)
Discussion started by: vkalya
1 Replies

6. Shell Programming and Scripting

Create multiple users with individual passwords to users

hi, i am new to shell scripts i write a shell script to create multiple users but i need to give passwords to that users while creating users, command to write this script (1 Reply)
Discussion started by: DONFOX
1 Replies

7. Shell Programming and Scripting

Script to add new users to a group on multiple servers using SSH

Hi Experts, I am new to scripting. We have around 400 Linux servers in our environment. I want to add a new user to a perticular group on all the servers using SSH. Requirements: 1) Need to take the server names from a text file. 2) Login into each server and check whether perticular... (1 Reply)
Discussion started by: Satya1983
1 Replies

8. Shell Programming and Scripting

Script To Delete User Accounts On Multiple Servers

Hello All, The servers in question are AIX/Unix servers. I was hoping to find a scripting solution where I could use one server as a jump server and run a script that would check each server for a user account (the source file for the user accounts would be a text file or csv file) , and delete... (4 Replies)
Discussion started by: k45bryant
4 Replies

9. Shell Programming and Scripting

Script to delete users in the servers

Hi Team, Hope you are doing good.I am new to scripting.I have a requirement of deleting around 10 users in 100 servers.It is very time consuming by logging into each servers and delete the user.Here I have redhat 6 ,Suse linux 10&11 environment servers. In one set of servers I have... (5 Replies)
Discussion started by: muraliinfy04
5 Replies

10. Shell Programming and Scripting

Shell script for creating multiple users with password

for UserName in `cat users` ; do useradd -d /u02 -s /usr/libexec/openssh/sftp-server -G ftp-users $UserName ; PassWord=$( echo $( tr '' '' <<< ${UserName:0:1} )${UserName:1} ) ; echo "$PassWord@123" | passwd $UserName --stdin ; done can some one explain what the bold text do Please use... (5 Replies)
Discussion started by: James0806
5 Replies
exit(1) 							   User Commands							   exit(1)

NAME
exit, return, goto - shell built-in functions to enable the execution of the shell to advance beyond its sequence of steps SYNOPSIS
sh exit [n] return [n] csh exit [( expr )] goto label ksh *exit [n] *return [n] ksh93 +exit [n] +return [n] DESCRIPTION
sh exit causes the calling shell or shell script to exit with the exit status specified by n. If n is omitted the exit status is that of the last command executed (an EOF also causes the shell to exit.) return causes a function to exit with the return value specified by n. If n is omitted, the return status is that of the last command exe- cuted. csh exit causes the calling shell or shell script to exit, either with the value of the status variable or with the value specified by the expression expr. The goto built-in uses a specified label as a search string amongst commands. The shell rewinds its input as much as possible and searches for a line of the form label: possibly preceded by space or tab characters. Execution continues after the indicated line. It is an error to jump to a label that occurs between a while or for built-in command and its corresponding end. ksh exit causes the calling shell or shell script to exit with the exit status specified by n. The value is the least significant 8 bits of the specified status. If n is omitted then the exit status is that of the last command executed. When exit occurs when executing a trap, the last command refers to the command that executed before the trap was invoked. An end-of-file also causes the shell to exit except for a shell which has the ignoreeof option (See set below) turned on. return causes a shell function or '.' script to return to the invoking script with the return status specified by n. The value is the least significant 8 bits of the specified status. If n is omitted then the return status is that of the last command executed. If return is invoked while not in a function or a '.' script, then it is the same as an exit. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a variable assignment. This means that tilde substitution is performed after the = sign and word splitting and file name genera- tion are not performed. ksh93 exit is shell special built-in that causes the shell that invokes it to exit. Before exiting the shell, if the EXIT trap is set, it is invoked. If n is specified, it is used to set the exit status. return is a shell special built-in that causes the function or dot script that invokes it to exit. If return is invoked outside of a func- tion or dot script it is equivalent to exit. If return is invoked inside a function defined with the function reserved word syntax, then any EXIT trap set within the function is invoked in the context of the caller before the function returns. If n is specified, it is used to set the exit status. On this manual page, ksh93 commands that are preceded by one or two + symbols are special built-in commands and are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. They are not valid function names. 5. Words following a command preceded by ++ that are in the format of a variable assignment are expanded with the same rules as a variable assignment. This means that tilde substitution is performed after the = sign and field splitting and file name genera- tion are not performed. EXIT STATUS
ksh93 If n is specified for exit, the exit status is the least significant eight bits of the value of n. Otherwise, the exit status is the exit status of preceding command. When invoked inside a trap, the preceding command means the command that invoked the trap. If n is specified for return, the exit status is the least significant eight bits of the value of n. Otherwise, the exit status is the exit status of preceding command. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
break(1), csh(1), ksh(1), ksh93(1), sh(1), attributes(5) SunOS 5.11 2 Nov 2007 exit(1)
All times are GMT -4. The time now is 08:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy