Sponsored Content
Full Discussion: script for creating aix user
Operating Systems AIX script for creating aix user Post 302183878 by bakunin on Thursday 10th of April 2008 04:42:52 AM
Old 04-10-2008
@prichard & Yac: Sorry, but i do not think it is that simple. To be useful such a script will have to deal with several error conditions. What you get out of "smitty user" is simply a wrapper for the "mkuser" command.

For instance assume the following situation: The script is called to create a user "foo" with UID 42. The following errors now could occur and should be reported back with different error levels from the script:

- a user "foo" exists already with uid=42 (=the user exists)

- a user "foo" exists with uid=43 (username already taken)

- a user "bar" exists with uid=42 (userid already taken)

- a user "foo" with uid=43 and a user "bar" with uid=42 exist already

How about other errors, like (unsorted): the script not being called by root, unable to create the home directory, the username is not a legal one, the uid is not legal, ..... (and i don't even mention the errors connected with the group memberships)

True, the last step would be to call "mkuser" and be done, but the necessary checks before look like an interesting programming task.

I hope this helps.

bakunin
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

creating user accounts in AIX

Hello all: I am new to UNIX and I am given the responsibility of administering a UNIX machine recently. The system is a IBM AIX 3.1. As a part of my duties I recently created some user accounts using "smit". It looked as if everything went well. But, after creating the account, I logged into... (3 Replies)
Discussion started by: pdepa
3 Replies

2. AIX

Limiting length of user in while creating user

Hi all, I am a newbe to aix 5.2. I want to specify the characters used by users while creating user in aix like specifying the length of the password should i use some sript for that if it is then please let me know how to do this if yes give me the link for the scripts. Thanks in advance ... (2 Replies)
Discussion started by: Satya Mishra
2 Replies

3. UNIX for Dummies Questions & Answers

AIX:creating user with username more than 8 chars

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa (0 Replies)
Discussion started by: anuafs84
0 Replies

4. Shell Programming and Scripting

Creating and Executing a script of aliases in AIX

hi, I am trying to create a script in AIX (5.3 I think), then run it. here's what I have: /home/me $ vi first.aliases ... alias cdblah='cd /blah' alias cdho='cd /ho' alias ssr='sudo su - random' ~ ...end of first.aliases /home/me $ ./first.aliases /home/me $ ssr ksh: ssr: not found.... (2 Replies)
Discussion started by: heetertc
2 Replies

5. Shell Programming and Scripting

Creating oracle user and giving him grants using shell script

Hi , I want to write a shell script that can create oracle database user and grants permission to this user. Thanks & Regards, Deepak (4 Replies)
Discussion started by: Deepakjha
4 Replies

6. Shell Programming and Scripting

Hp-UX, SUSE, and AIX LDAP User Script Help

Hi, I have been asked to create a ksh script that will search against an LDAP directory from various HP-UX, SUSE, and AIX 5.3 and 6.1 machines. The objective is to verify the boxes are successfully authenticating users from the LDAP store. This is something I've never done, and I could use... (0 Replies)
Discussion started by: tekster2
0 Replies

7. AIX

AIX How to run a Shell Script by changing the User

Hi All, Currently our application is running on the server having AIX 5.3 OS. What we intend to do is to run a shell script owned by another user and needs to be run as that particular user. I was trying to create a shell script using the su command before running the actual script (which... (4 Replies)
Discussion started by: acoomer
4 Replies

8. Shell Programming and Scripting

How to write bash script for creating user on multiple Linux hosts?

I wonder whether someone can help me with what I'm trying to achieve Basically, the objective is one script to create new user on more than 70 linux hosts if required. Everything works apart from the highlighted part. It gave me an output passwd: Unknown user name ''. when try to set... (35 Replies)
Discussion started by: fugeulu
35 Replies

9. Shell Programming and Scripting

Creating a script requiring a pause for user input

Hi I'm trying to create a basic script that pauses for user input to verify a file name before generating the output. I have numerous SSL certificate files which I am trying to determine the expiry date so what I'm trying to do is write a script so that is pauses to request the name of the .pem... (9 Replies)
Discussion started by: Buddyluv
9 Replies

10. UNIX for Advanced & Expert Users

Prevent user from creating new user from his login

Hi Experts, Need your support Redhat 6.5 I want to create a user with all(read, write, execute) privileges except that user should not be able to create any new user from his login to perform any task. (10 Replies)
Discussion started by: as7951
10 Replies
Template::Plugin::File(3)				User Contributed Perl Documentation				 Template::Plugin::File(3)

NAME
Template::Plugin::File - Plugin providing information about files SYNOPSIS
[% USE File(filepath) %] [% File.path %] # full path [% File.name %] # filename [% File.dir %] # directory DESCRIPTION
This plugin provides an abstraction of a file. It can be used to fetch details about files from the file system, or to represent abstract files (e.g. when creating an index page) that may or may not exist on a file system. A file name or path should be specified as a constructor argument. e.g. [% USE File('foo.html') %] [% USE File('foo/bar/baz.html') %] [% USE File('/foo/bar/baz.html') %] The file should exist on the current file system (unless "nostat" option set, see below) as an absolute file when specified with as leading '"/"' as per '"/foo/bar/baz.html"', or otherwise as one relative to the current working directory. The constructor performs a "stat()" on the file and makes the 13 elements returned available as the plugin items: dev ino mode nlink uid gid rdev size atime mtime ctime blksize blocks e.g. [% USE File('/foo/bar/baz.html') %] [% File.mtime %] [% File.mode %] ... In addition, the "user" and "group" items are set to contain the user and group names as returned by calls to "getpwuid()" and "getgrgid()" for the file "uid" and "gid" elements, respectively. On Win32 platforms on which "getpwuid()" and "getgrid()" are not available, these values are undefined. [% USE File('/tmp/foo.html') %] [% File.uid %] # e.g. 500 [% File.user %] # e.g. abw This user/group lookup can be disabled by setting the "noid" option. [% USE File('/tmp/foo.html', noid=1) %] [% File.uid %] # e.g. 500 [% File.user %] # nothing The "isdir" flag will be set if the file is a directory. [% USE File('/tmp') %] [% File.isdir %] # 1 If the "stat()" on the file fails (e.g. file doesn't exists, bad permission, etc) then the constructor will throw a "File" exception. This can be caught within a "TRY...CATCH" block. [% TRY %] [% USE File('/tmp/myfile') %] File exists! [% CATCH File %] File error: [% error.info %] [% END %] Note the capitalisation of the exception type, '"File"', to indicate an error thrown by the "File" plugin, to distinguish it from a regular "file" exception thrown by the Template Toolkit. Note that the "File" plugin can also be referenced by the lower case name '"file"'. However, exceptions are always thrown of the "File" type, regardless of the capitalisation of the plugin named used. [% USE file('foo.html') %] [% file.mtime %] As with any other Template Toolkit plugin, an alternate name can be specified for the object created. [% USE foo = file('foo.html') %] [% foo.mtime %] The "nostat" option can be specified to prevent the plugin constructor from performing a "stat()" on the file specified. In this case, the file does not have to exist in the file system, no attempt will be made to verify that it does, and no error will be thrown if it doesn't. The entries for the items usually returned by "stat()" will be set empty. [% USE file('/some/where/over/the/rainbow.html', nostat=1) [% file.mtime %] # nothing METHODS
All "File" plugins, regardless of the "nostat" option, have set a number of items relating to the original path specified. path The full, original file path specified to the constructor. [% USE file('/foo/bar.html') %] [% file.path %] # /foo/bar.html name The name of the file without any leading directories. [% USE file('/foo/bar.html') %] [% file.name %] # bar.html dir The directory element of the path with the filename removed. [% USE file('/foo/bar.html') %] [% file.name %] # /foo ext The file extension, if any, appearing at the end of the path following a '"."' (not included in the extension). [% USE file('/foo/bar.html') %] [% file.ext %] # html home This contains a string of the form '"../.."' to represent the upward path from a file to its root directory. [% USE file('bar.html') %] [% file.home %] # nothing [% USE file('foo/bar.html') %] [% file.home %] # .. [% USE file('foo/bar/baz.html') %] [% file.home %] # ../.. root The "root" item can be specified as a constructor argument, indicating a root directory in which the named file resides. This is otherwise set empty. [% USE file('foo/bar.html', root='/tmp') %] [% file.root %] # /tmp abs This returns the absolute file path by constructing a path from the "root" and "path" options. [% USE file('foo/bar.html', root='/tmp') %] [% file.path %] # foo/bar.html [% file.root %] # /tmp [% file.abs %] # /tmp/foo/bar.html rel(path) This returns a relative path from the current file to another path specified as an argument. It is constructed by appending the path to the '"home"' item. [% USE file('foo/bar/baz.html') %] [% file.rel('wiz/waz.html') %] # ../../wiz/waz.html EXAMPLES
[% USE file('/foo/bar/baz.html') %] [% file.path %] # /foo/bar/baz.html [% file.dir %] # /foo/bar [% file.name %] # baz.html [% file.home %] # ../.. [% file.root %] # '' [% file.abs %] # /foo/bar/baz.html [% file.ext %] # html [% file.mtime %] # 987654321 [% file.atime %] # 987654321 [% file.uid %] # 500 [% file.user %] # abw [% USE file('foo.html') %] [% file.path %] # foo.html [% file.dir %] # '' [% file.name %] # foo.html [% file.root %] # '' [% file.home %] # '' [% file.abs %] # foo.html [% USE file('foo/bar/baz.html') %] [% file.path %] # foo/bar/baz.html [% file.dir %] # foo/bar [% file.name %] # baz.html [% file.root %] # '' [% file.home %] # ../.. [% file.abs %] # foo/bar/baz.html [% USE file('foo/bar/baz.html', root='/tmp') %] [% file.path %] # foo/bar/baz.html [% file.dir %] # foo/bar [% file.name %] # baz.html [% file.root %] # /tmp [% file.home %] # ../.. [% file.abs %] # /tmp/foo/bar/baz.html # calculate other file paths relative to this file and its root [% USE file('foo/bar/baz.html', root => '/tmp/tt2') %] [% file.path('baz/qux.html') %] # ../../baz/qux.html [% file.dir('wiz/woz.html') %] # ../../wiz/woz.html AUTHORS
Michael Stevens wrote the original "Directory" plugin on which this is based. Andy Wardley split it into separate "File" and "Directory" plugins, added some extra code and documentation for "VIEW" support, and made a few other minor tweaks. COPYRIGHT
Copyright 2000-2007 Michael Stevens, Andy Wardley. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Template::Plugin, Template::Plugin::Directory, Template::View perl v5.12.1 2008-11-13 Template::Plugin::File(3)
All times are GMT -4. The time now is 09:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy