Sponsored Content
Top Forums Shell Programming and Scripting Perl Script on Solaris and HP UX Post 302788403 by yadavricky on Monday 1st of April 2013 06:08:36 PM
Old 04-01-2013
RedHat Useradd cmd in solaris and HPUX

Dear All,
I am having a script which is using the useradd command to create a new user.

it was working fine in solaris but now in HP UX i am getting a prolem. though almost al the option which are available with command are same.

i am using below options
Code:
                [-c comment]
		[-m [-k skel_dir]]
		[-d dir] 
		[-g group] - Security Groupname
		[-G group [, group...]]
		[-s shell]
		[-k skel_dir]

when the script will run it will add the user in /etc/passwd and first the new created account will in locked status.

below is the code which is used to create a account.
Code:
		my $pUserID = shift(@_);
   		my $su;
		my $Cmd = $myConfig::Configuration{useradd};

		my @CmdArgs =  ('-c', 'my Account for ' . $myConfig::Configuration{InstanceName} . ' instance',
				'-m', '-d', $myConfig::Configuration{AccountHome}."/".lc($pUserID),
				'-g', $myConfig::Configuration{SecurityGroupName},
				'-G', 'myscr',
				'-s', '/bin/ksh',
				'-k', $myConfig::Configuration{AccountHome}."/".$myConfig::Configuration{StdAccountName},lc($pUserID));
		$su = Sudo->new(
				{
				 sudo         => $myConfig::Configuration{sudo}
				,sudo_args    => ''
		                ,username     => "root"
				,program      => $Cmd
				,program_args => \@CmdArgs
				}

when i run it in HP US i get below entry in Passwd file
Code:
ARRAY(0x6000000000aca598):x:117:20::/home/ARRAY(0x6000000000aca598):/sbin/sh		ARRAY(0x6000000000aca638):x:118:20::/home/ARRAY(0x6000000000aca638):/sbin/sh

can somebody guide me about error.

To unlock the account i have planned to use /usr/lbin/modprpw with -k which is silmilar to passwd -u but no idea what will be outcome.

Please suggest why strange entry in /ect/passwd file and suggestion

Last edited by Franklin52; 04-02-2013 at 08:49 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Perl] Accessing array elements within a sed command in Perl script

I am trying to use a script to replace the header of each file, whose filename are stored within the array $test, using the sed command within a Perl script as follows: $count = 0; while ( $count < $#test ) { `sed -e 's/BIOGRF 321/BIOGRF 332/g' ${test} > 0`; `cat 0 >... (2 Replies)
Discussion started by: userix
2 Replies

2. Shell Programming and Scripting

Solaris+Perl script to get process start date

Hi all, after reading the post: * https://www.unix.com/solaris/101653-how-get-process-start-date-time-solaris.html I wrote my perl script and it worked like a charm. This script is called every 5 minutes by the monitoring server crontab and is executed on the remote network elements via ssh (the... (6 Replies)
Discussion started by: Evan
6 Replies

3. Shell Programming and Scripting

perl/unix: script in command line works but not in perl

so in unix this command works works and shows me a list of directories find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt but when i try running a perl script to run this command my $query = 'find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt';... (2 Replies)
Discussion started by: kpddong
2 Replies

4. Shell Programming and Scripting

Perl :How to print the o/p of a Perl script on console and redirecting same in log file @ same time.

How can i print the output of a perl script on a unix console and redirect the same in a log file under same directory simultaneously ? Like in Shell script, we use tee, is there anything in Perl or any other option ? (2 Replies)
Discussion started by: butterfly20
2 Replies

5. Shell Programming and Scripting

HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

Hi all, Not sure if this should be in the programming forum, but I believe it will get more response under the Shell Programming and Scripting FORUM. Am trying to write a customized df script in Perl and need some help with regards to using arrays and file handlers. At the moment am... (3 Replies)
Discussion started by: newbie_01
3 Replies

6. Shell Programming and Scripting

calling a perl script with arguments from a parent perl script

I am trying to run a perl script which needs input arguments from a parent perl script, but doesn't seem to work. Appreciate your help in this regard. From parent.pl $input1=123; $input2=abc; I tried calling it with system("/usr/bin/perl child.pl $input1 $input2"); and `perl... (1 Reply)
Discussion started by: grajp002
1 Replies

7. Shell Programming and Scripting

executing perl script from another perl script : NOT WORKING

Hi Folks, I have 2 perl scripts and I need to execute 2nd perl script from the 1st perl script in WINDOWS. In the 1st perl script that I had, I am calling the 2nd script main.pl =========== print "This is my main script\n"; `perl C:\\Users\\sripathg\\Desktop\\scripts\\hi.pl`; ... (3 Replies)
Discussion started by: giridhar276
3 Replies

8. Shell Programming and Scripting

Perl : embedding java script with cgi perl script

Hi All, I am aware that html tags can be embedded in cgi script as below.. In the same way is it possible to embed the below javascript in perl cgi script ?? print("<form action="action.htm" method="post" onSubmit="return submitForm(this.Submitbutton)">"); print("<input type = "text"... (1 Reply)
Discussion started by: scriptscript
1 Replies

9. Shell Programming and Scripting

Excuting perl script from within a perl script with variables.

Not sure what I am doing wrong here, but I can print the list with no issue. Just a blank screen with the 'do'. #!/usr/bin/perl open FILE, "upslist.txt"; while ($line=<FILE>){ if ($line=~/^(.*?),(.*?)$/){ #print "ups:$1 string:$2\n"; do 'check_snmp_mgeups-0.1.pl -H $1 -C $2'; } ... (1 Reply)
Discussion started by: mrlayance
1 Replies

10. Programming

PERL: In a perl-scripttTrying to execute another perl-script that SETS SOME VARIABLES !

I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open()) I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies
KDB 
:: High Level methods(3) Library Functions Manual KDB :: High Level methods(3) NAME
KDB :: High Level methods - High level methods to access the Key database. Functions int kdbGetKey (KDB *handle, Key *dest) int kdbSetKey (KDB *handle, const Key *key) int kdbGetString (KDB *handle, const char *keyname, char *returned, size_t maxSize) int kdbSetString (KDB *handle, const char *keyname, const char *value) int kdbRemove (KDB *handle, const char *keyname) ssize_t kdbGetByName (KDB *handle, KeySet *returned, const char *name, option_t options) Detailed Description High level methods to access the Key database. To use them: #include <kdb.h> These methods are higher level. They use kdbOpen(), kdbClose(), kdbGet() and kdbSet() methods to do their job, and don't have to be reimplemented for a different backend. These functions avoid limitations through not implemented capabilities. This will of course cost some effort, so read through the description carefully and decide if it is appropriate for your problem. Binding writers don't have to implement these functions, use features of the binding language instead. But you can use these functions as ideas what high level methods may be useful. Don't use writing single keys in a loop, prefer always writing out a keyset! Function Documentation ssize_t kdbGetByName (KDB *handle, KeySet *returned, const char *name, option_toptions) This method is similar kdbGet() but the path is given by a string. When it is not possible to make a key out of that string -1 is returned . When parentName starts with / cascading will be used and both keys from user and system will be fetched. A typically app with about 3000 keys may have this line: KDB *handle = kdbOpen(); KeySet *myConfig = (4096, KS_END); ssize_t ret = kdbGetByName (handle, myConfig, '/sw/app/current', 0); // check ret and work with keyset myConfig ksDel (myConfig); kdbClose (handle); * myConfig will be loaded with keys from system/sw/app/current but also user/sw/app/current. When one of these kdbGet() fails -1 will be returned, but the other kdbGet() will be tried too. Parameters: handle contains internal information of opened key database name the name where to get the keys below returned the (pre-initialized) KeySet returned with all keys found options ORed options to control approaches Unlike to kdbGet() is KDB_O_POP set per default. Returns: number of keys contained by returned -1 on failure -1 when name is no valid key -1 on NULL pointer See also: kdbGet() int kdbGetKey (KDB *handle, Key *dest) Fully retrieves the passed key from the backend storage. The backend will try to get the key, identified through its name. It uses kdbGet() for retrieving the key and copies the found data to dest. While kdbGetKey() is perfect for a simple get of a specific key, kdbGet() and kdbGetByName() gives you more control over the keyset. Parameters: handle contains internal information of opened key database dest a pointer to a Key that has a name set Returns: 0 on success -1 on failure -1 on NULL pointer See also: kdbSetKey() to set a single Key :: Basic Methods commandGet() code in KDB :: Low Level Methods command for usage example kdbGet() and kdbGetByName() to have more control over KeySet :: Class Methods and options int kdbGetString (KDB *handle, const char *keyname, char *returned, size_tmaxSize) A high-level method to get a key value, by key name. This method gets a backend from any backend with kdbGetKey() and extracts the string and store it into returned. It only works with string keys. This method gives you the direct relation between a keyname and the value, without any kdb specific structures. Use it when you just want some values out of the kdb namespace. You need to know the maximum string length of the object. That could be the case when you e.g. save a path which is limited with MAX_PATH. KDB *handle = kdbOpen(); char buffer [MAX_PATH]; if (kdbGetString(handle, 'user/key/to/get/pathname', buffer, sizeof(buffer)) == -1) { // handle error cases } else { printf ('The keys value is %s0, buffer); } kdbClose(handle); Parameters: handle contains internal information of opened key database keyname the name of the key to receive the value returned a buffer to put the key value maxSize the size of the buffer Returns: 0 on success -1 on failure -1 on NULL pointers -1 if maxSize is 0 or larger than SSIZE_MAX See also: kdbSetString() and kdbRemove() to set and remove a string kdbGetKey(), keySetKey() to work with Keys kdbGet() and kdbGetByName() for full access to KDB Backends :: Internal Helper for Elektra datastructures int kdbRemove (KDB *handle, const char *keyname) Remove a key by its name from the backend storage. With kdbSetString() its only possible to set a key with an empty string. To really remove a key in a highlevel way you can use this method. Parameters: handle contains internal information of opened key database keyname the name of the key to be removed Returns: 0 on success -1 on failure -1 on NULL pointers See also: together with kdbSetString() and kdbGetString() a highlevel interface for KDB :: Low Level Methods commandRemove() code in KDB :: Low Level Methods command for usage example int kdbSetKey (KDB *handle, const Key *key) Sets key in the backend storage. While kdbSetKey() is perfect for a simple get of a specific key, kdbGet() and kdbGetByName() gives you more control over the keyset. Parameters: handle contains internal information of opened key database key Key to set Returns: 0 on success -1 on failure -1 on NULL pointer See also: kdbGetKey() to get a single Key :: Basic Methods kdbSet() for more control over KeySet :: Class Methods and options commandSet() code in KDB :: Low Level Methods command for usage example int kdbSetString (KDB *handle, const char *keyname, const char *value) A high-level method to set a value to a key, by key name. It will check if key exists first, and keep its metadata. So you'll not loose the previous key comment. This will set a text key. So if the key was previously a binary it will be retyped as string. Parameters: handle contains internal information of opened key database keyname the name of the key to receive the value value the value to be set Returns: 0 on success -1 on NULL pointers -1 on failure See also: kdbGetString(), keySetString(), kdbSetKey() Author Generated automatically by Doxygen for Elektra Projekt from the source code. Elektra Projekt Fri Aug 26 2011 KDB :: High Level methods(3)
All times are GMT -4. The time now is 04:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy