public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* cygwin perl useradd command
@ 2008-05-09 13:29 Jaspreet Singh
  0 siblings, 0 replies; 4+ messages in thread
From: Jaspreet Singh @ 2008-05-09 13:29 UTC (permalink / raw)
  To: cygwin

hey guys,

 anybody has useradd command on cygwin. Here's something interesting.
i wrote a perl script for useradd command. it takes following arguments

 -u	:	Username\n";
 -p	:	Password\n";
 -g	:	Initial Group\n";
 -c	:	Comments\n";
 -d	:	Home Directory\n";
 -s	:	Shell\n";
 -m	:	Copy /etc/skel/* to <home_directory>\n";
 -h	:	Show usage\n";
 -v	:	Show version\n";
 --help	:	Show usage\n";
 --version	:	Show version\n";

like useradd.pl -u username -p password

then it resolves all given arguments, like -u, -p, -c and others

then adds "_usr" at the end of the username passed to script

then it creates a NET USER /ADD command with /COMMENTS: and /FULLNAME: if -c is found in arguments

then it execute it

confirm it by executing mkpasswd -l -u username command, it returns usersting like 

username:password:UID:GID:comments:home_dir:user_shell 

or

error

if username is found in output then new user is added to windows

NOW, this is where i am stuck when new user is suppose to be added to /etc/passwd file

the thing i want to have is enable this script to add user and group of same name to passwd and group file

where i am stuck is that it can add default userstring output from mkpasswd command to /etc/passwd file. but what i want is to verify if theres any user with same username (username minus "_usr") in passwd file if there is it is noty even suppose to add user to windows. if there is a group with same username in group file it is suppose to add a virtual user like

<username minus "_usr">:UID:<GID of group with same username>:comments:home_dir:user_shell

to passwd file.

if anybody even understand what i am tring to do and can complete this perl script. please reply

if anybody completes this then that person can also create usermod, userdel, groupadd, groupmod, and groupdel perl scripts to 

THIS WILL BE A REALY COOL THING IN CYGWIN

------------------------------------------------
HERES MY useradd.pl SAMPLE
------------------------------------------------

#!/usr/bin/perl

$ArgsCount = $#ARGV + 1;
$version = "Open Source Perl useradd Script For cygwin\n";
use constant vbcrlf => "\r\n";

foreach $i (0 .. $#ARGV) 
{
  if ($ARGV[$i] eq "-v") 
	{
		die $version;
	}
  elsif ($ARGV[$i] eq "--version")
	{
		die $version;
	}
  elsif ($ARGV[$i] eq "-h")
	{
		print $version;
		print "\n";
		print "usage :\n";
		print " -u	:	Username\n";
		print " -p	:	Password\n";
		print " -g	:	Initial Group\n";
		print " -c	:	Comments\n";
		print " -d	:	Home Directory\n";
		print " -s	:	Shell\n";
		print " -m	:	Copy /etc/skel/* to <home_directory>\n";
		print " -h	:	Show usage\n";
		print " -v	:	Show version\n";
		print " --help	:	Show usage\n";
		die " --version	:	Show version\n";
	}
  elsif ($ARGV[$i] eq "--help")
	{
		print $version;
		print "\n";
		print "usage :\n";
		print " -u	:	Username\n";
		print " -p	:	Password\n";
		print " -g	:	Initial Group\n";
		print " -c	:	Comments\n";
		print " -d	:	Home Directory\n";
		print " -s	:	Shell\n";
		print " -m	:	Copy /etc/skel/* to <home_directory>\n";
		print " -h	:	Show usage\n";
		print " -v	:	Show version\n";
		print " --help	:	Show usage\n";
		die " --version	:	Show version\n";
	}
}

$username = "";
$password = "";
$UID = "";
$GID = "";
$comments = "";
$home = "";
$shell = "";


foreach $i (0 .. $#ARGV) 
{

if (($ARGV[$i] eq "-u") && ($username eq ""))
	{
	
   if (($ARGV[$i + 1] eq "-u") || ($ARGV[$i + 1] eq "-p")
      || ($ARGV[$i + 1] eq "-g") || ($ARGV[$i + 1] eq "-c")
      || ($ARGV[$i + 1] eq "-d") || ($ARGV[$i + 1] eq "-s")
      || ($ARGV[$i + 1] eq "-m"))
      {
        die "command failed.\n";
      }  
   else
	  {
        $username = $ARGV[$i + 1];
      }

	}
	
elsif (($ARGV[$i] eq "-p") && ($password eq ""))
	{
	
   if (($ARGV[$i + 1] eq "-u") || ($ARGV[$i + 1] eq "-p")
      || ($ARGV[$i + 1] eq "-g") || ($ARGV[$i + 1] eq "-c")
      || ($ARGV[$i + 1] eq "-d") || ($ARGV[$i + 1] eq "-s")
      || ($ARGV[$i + 1] eq "-m"))
      {
        #die "command failed.";
      }  
   else
	  {
        $password = $ARGV[$i + 1];
      }

	}

elsif (($ARGV[$i] eq "-g") && ($GID eq ""))
	{
	
   if (($ARGV[$i + 1] eq "-u") || ($ARGV[$i + 1] eq "-p")
      || ($ARGV[$i + 1] eq "-g") || ($ARGV[$i + 1] eq "-c")
      || ($ARGV[$i + 1] eq "-d") || ($ARGV[$i + 1] eq "-s")
      || ($ARGV[$i + 1] eq "-m"))
      {
        #die "command failed.";
      }  
   else
	  {
        $GID = $ARGV[$i + 1];
      }

	}

elsif (($ARGV[$i] eq "-c") && ($comments eq ""))
	{
	
   if (($ARGV[$i + 1] eq "-u") || ($ARGV[$i + 1] eq "-p")
      || ($ARGV[$i + 1] eq "-g") || ($ARGV[$i + 1] eq "-c")
      || ($ARGV[$i + 1] eq "-d") || ($ARGV[$i + 1] eq "-s")
      || ($ARGV[$i + 1] eq "-m"))
      {
        #die "command failed.";
      }  
   else
	  {
        $comments = $ARGV[$i + 1];
      }

	}

elsif (($ARGV[$i] eq "-d") && ($home eq ""))
	{
	
   if (($ARGV[$i + 1] eq "-u") || ($ARGV[$i + 1] eq "-p")
      || ($ARGV[$i + 1] eq "-g") || ($ARGV[$i + 1] eq "-c")
      || ($ARGV[$i + 1] eq "-d") || ($ARGV[$i + 1] eq "-s")
      || ($ARGV[$i + 1] eq "-m"))
      {
        #die "command failed.";
      }  
   else
	  {
        $home = $ARGV[$i + 1];
      }

	}

elsif (($ARGV[$i] eq "-s") && ($shell eq ""))
	{
	
   if (($ARGV[$i + 1] eq "-u") || ($ARGV[$i + 1] eq "-p")
      || ($ARGV[$i + 1] eq "-g") || ($ARGV[$i + 1] eq "-c")
      || ($ARGV[$i + 1] eq "-d") || ($ARGV[$i + 1] eq "-s")
      || ($ARGV[$i + 1] eq "-m"))
      {
        #die "command failed.";
      }  
   else
	  {
        $shell = $ARGV[$i + 1];
      }

	}
	
}

if ($username eq "")
	{
		print "Cant find username\n";
		print "\n";
		print $version;
		print "\n";
		print "usage :\n";
		print " -u	:	Username\n";
		print " -p	:	Password\n";
		print " -g	:	Initial Group\n";
		print " -c	:	Comments\n";
		print " -d	:	Home Directory\n";
		print " -s	:	Shell\n";
		print " -m	:	Copy /etc/skel/* to <home_directory>\n";
		print " -h	:	Show usage\n";
		print " -v	:	Show version\n";
		print " --help	:	Show usage\n";
		die " --version	:	Show version\n";
	}

$cmdline = "";
$cmdline = "NET USER /ADD ".$username."_usr";
if ($password ne "")
	{
		$cmdline = $cmdline." ".$password;
	}
if ($comments ne "")
	{
		$cmdline = $cmdline." /COMMENT:"."\"".$comments."\""." /FULLNAME:"."\"".$comments."\"";
	}
$CMD = `$cmdline 2>&1`;
$temp = $username."_usr";
$CMDMK = `mkpasswd -l -u $temp 2>&1`;
chomp;
($login, $npasswd, $nuid, $ngid, $ngcos, $nhome, $nshell) = split(/:/,$CMDMK);     
if ($login ne $temp)
	{
		die "Command failed.\n";
	}
$userstring = $username.":".$npasswd.":".$nuid.":".


#print $username.":".$password.":".$UID.":".$GID.":".$comments.":".$home.":".$shell."\n"; 

#print "Not dead";







      Meet people who discuss and share your passions. Go to http://in.promos.yahoo.com/groups/bestofyahoo/


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: cygwin perl useradd command
       [not found] <Pine.GSO.4.64.0805091314490.5627@brains.eng.cse.dmu.ac.uk>
  2008-05-09 15:45 ` Jaspreet Singh
@ 2008-05-10 19:51 ` Jaspreet Singh
  1 sibling, 0 replies; 4+ messages in thread
From: Jaspreet Singh @ 2008-05-10 19:51 UTC (permalink / raw)
  To: Hugh Sasse; +Cc: cygwin

alright now i completed. this may be not optimized code but whatever this is what i came up with

========================================================================

#!/usr/bin/perl

$userprefix  = "cygusr_";
$groupprefix = "cyggrp_";

# Function Output Help/Usage
sub printhelp
{
		print "Perl useradd command for cygwin.\n";
		print "\n";
		print "usage :\n";
		print " -u	:	Username\n";
		print " -p	:	Password\n";
		print " -g	:	Initial Group\n";
		print " -c	:	Comments\n";
		print " -d	:	Home Directory\n";
		print " -s	:	Shell\n";
		print " -m	:	Copy /etc/skel/* to <home_directory>\n";
		print " -h	:	Show usage\n";

};

   # Resolve passed arguments
   $usr        = "";   # Username
   $pass       = "";   # Password
   $pUID       = "";   # UID
   $pGID       = "";   # GID (Initial Group)
   $comm       = "";   # Comments
   $home       = "";   # Home Directory
   $shell      = "";   # User Shell
   $createhome = "";
   while ($ARGV[$i])
       	{
		if ($ARGV[$i] eq "-h")
                    {
                       die &printhelp;
                    }
                elsif ($ARGV[$i] eq "-u")
                    {
                       $usr = $ARGV[$i + 1];
                    }
                elsif ($ARGV[$i] eq "-p")
                    {
                       $pass = $ARGV[$i + 1];
                    }
                elsif ($ARGV[$i] eq "-g")
                    {
                       $pGID = $ARGV[$i + 1];
                    }
                elsif ($ARGV[$i] eq "-c")
                    {
                       $comm = $ARGV[$i + 1];
                    }
                elsif ($ARGV[$i] eq "-d")
                    {
                       $home = $ARGV[$i + 1];
                    }
                elsif ($ARGV[$i] eq "-s")
                    {
                       $shell = $ARGV[$i + 1];
                    }
                elsif ($ARGV[$i] eq "-m")
                    {
                       $createhome = $ARGV[$i];
                    }
		$i++;
	}

   if ($usr eq "")
      {
         die &printhelp;
      }

   if ($pGID eq "")
      {
         $pGID = "default";
      }
   else
      {
       # If GID is specified in the arguments then we find out the
       # GID Numeric

       # for cygwin verification we open : /etc/group

       open(GROUP, "</etc/group") || die "Can't open group for reading.\n";
       while (<GROUP>)
             {
               ($gname, $sid, $ggid, $list) = split(/:/);
                if (($ggid eq $pGID) || ($gname eq $pGID))
	           {
                     $temp = $ggid;
	           }
	     }
       close(GROUP);
       if ($temp ne "")
          {
           $pGID = $ggid;
          }
       else
          {
           $pGID = "default";
          }
      }

   if ($comm eq "")
      {
         $comm = "CYGWIN User";
      }

   if ($home eq "")
      {
         $home = "/home/".$usr;
      }

   if ($shell eq "")
      {
         $shell = "/bin/bash";
      }

   # Temp Userstring
   $userstring = $usr.":".$pass.":".$pUID.":".$pGID.":".$comm.":".$home.":".$shell;
   # Username for windows
   $finalusr = $userprefix.$usr;

   #-------------------------------------------------------------------------#
   # There shouldn't be any user with $usr and $finalusr on widows or cygwin #
   #-------------------------------------------------------------------------#

   # Now we have to verify that there isn't any user with $usr username
   # on windows and in /etc/passwd file of cygwin for real user verificatoion.

   # for windows verification we use : /usr/bin/mkpasswd -l -u $usr

   $verifyusr = `/usr/bin/mkpasswd -l -u $usr 2>&1`;
   chop ($verifyusr);
   if ($verifyusr ne "mkpasswd (272): [2221] The user name could not be found.\r")
      {
       die "User with same user name already exists. see windows accounts.\n";
      }

   # for cygwin verification we open : /etc/passwd

   open(PASSWD, "</etc/passwd") || die "Can't open passwd for reading.\n";
   while (<PASSWD>)
      {
        ($name,$passwd,$uid,$gid, $gcos,$dir,$zshell) = split(/:/);
        if ($name eq $usr)
           {
            close(PASSWD);
       	    die "User with same user name already exists. see /etc/passwd..\n";
           }
      }
   close(PASSWD);

   # Now we have to verify that there isn't any user with $finalusr username
   # on windows and in /etc/passwd file of cygwin for real user verificatoion.

   # for windows verification we use : /usr/bin/mkpasswd -l -u $finalusr

   $verifyusr = `/usr/bin/mkpasswd -l -u $finalusr 2>&1`;
   chop ($verifyusr);
   if ($verifyusr ne "mkpasswd (272): [2221] The user name could not be found.\r")
      {
       die "User with same user name and prefix already exists. see windows accounts.\n";
      }

   # for cygwin verification we open : /etc/passwd

   open(PASSWD, "</etc/passwd") || die "Can't open passwd for reading.\n";
   while (<PASSWD>)
      {
        ($name,$passwd,$uid,$gid, $gcos,$dir,$zshell) = split(/:/);
        if ($name eq $finalusr)
           {
            close(PASSWD);
       	    die "User with same user name and prefix already exists. see /etc/passwd.\n";
           }
      }
   close(PASSWD);

   #-------------------------------------------------------#
   # There shouldn't be any group with $finalusr on widows #
   #-------------------------------------------------------#

   # Now we have to verify that there isn't any group with $finalusr username
   # on windows for real group verificatoion.

   $verifygroup = `/usr/bin/mkgroup -l -g $finalusr 2>&1`;
   $verifygroup = substr ($verifygroup,0,13);
   if ($verifygroup ne "mkgroup (255)")
      {
       die "Group with same username already exists. see windows groups.\n";
      }

   #------------------------------------------#
   # There must be NET USER command on widows #
   #------------------------------------------#

   # Now we create and execute NET USER /ADD $finalusr command.

   $CMD = "NET USER /ADD ".$finalusr;
   if ($pass ne "")
      {
       $CMD = $CMD." ".$pass;
      }
   if ($comm ne "")
      {
       $CMD = $CMD." /COMMENT:\"".$comm."\" /FULLNAME:\"".$comm."\"";
      }
   $CMD = `$CMD 2>&1`;
   #die $CMD."\n";

   # Now verify user with cygwin /usr/bin/mkpasswd -l -u $finalusr

   $CMDMK = `mkpasswd -l -u $finalusr 2>&1`;
   chomp;
   ($login, $npasswd, $nuid, $ngid, $ngcos, $nhome, $nshell) = split(/:/,$CMDMK);
   if ($login ne $finalusr)
   	{
   		die "NET USER /ADD command failed.\n";
   	}

   # Now we delete user from Users group on windows with
   # NET LOCALGROUP /DELETE Users $finalusr as windows assign it as
   # default group to all new users.

   $DELUSRGRP = `NET LOCALGROUP /DELETE Users $finalusr 2>&1`;

   # Now we get all user values

   $usr   = $usr;      # Virtual Username
   $pass  = $npasswd;  # Password entry used by cygwin
   $pUID  = $nuid;     # UID
   if ($pGID eq "default")
      {
       $pGID = $ngid;  # cygwin default GID if not found in argument
      }
   else
      {
       $pGID  = $pGID; # GID found in argument
      }
   $comm  = $ngcos;    # Comments entry used by cygwin
   $home  = $home;     # Home Directory found in arguments or defalut /home/<username>
   $shell = $shell;    # User Shell found in arguments or defalut /bin/bash

   #-----------------------------------------------------------------------------------#
   # This will overwrites GID in passed arrgument and cygwin default GID for new users #
   #-----------------------------------------------------------------------------------#

   # Now we find if group with same virtual username exists in
   # cygwin /etc/group. If found then the GID of user is changed
   # to be GID of group.

   # for cygwin verification we open : /etc/group

   open(GROUP, "</etc/group") || die "Can't open group for reading.\n";
   while (<GROUP>)
      {
        ($gname, $sid, $ggid, $list) = split(/:/);
        if ($gname eq $usr)
           {
             $temp = $ggid;
           }
      }
   close(GROUP);

   if ($temp ne "")
      {
       $pGID = $temp
      }
   else
      {
       die "Specified Group not found. see cygwin /etc/group.\n";
      }

   # Now we create virtual user userstring for cygwin /etc/passwd

   $userstring = $usr.":".$pass.":".$pUID.":".$pGID.":".$comm.":".$home.":".$shell;

   # Now we add to cygwin /etc/passwd file

   open(PASSWD, ">>/etc/passwd") or die "Unable to open /etc/passwd for appending";
   print PASSWD $userstring;
   close(PASSWD);

   if ($createhome eq "-m")
      {
       mkdir("$home",0755);
       #system("cp /etc/skel/.bash_profile $home/.bash_profile");
       #system("cp /etc/skel/.bashrc $home/.bashrc");
       #system("cp /etc/skel/.inputrc $home/.inputrc");
       #system("cp /etc/skel/.zshrc $home/.zshrc");
       #system("cp /etc/skel/.xinitrc $home/.xinitrc");
       #system("cp /etc/skel/.xserverrc $home/.xserverrc");
       #system("cp /etc/skel/.bash_logout $home/.bash_logout");
       #mkdir("$home/.mail",0777);
       #system("cp /etc/skel/.mail/mailbox $home/.mail/mailbox");
       #chown $pUID, $pGID, "$home/.mail";
       chown $pUID, $pGID, "$home";
      }

   print "New user added to system.\n";

==========================================================================

if any optimization anybody can do or any kinda error or mistake, you are welcome



      Meet people who discuss and share your passions. Go to http://in.promos.yahoo.com/groups/bestofyahoo/


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: cygwin perl useradd command
  2008-05-09 15:45 ` Jaspreet Singh
@ 2008-05-09 17:58   ` Hugh Sasse
  0 siblings, 0 replies; 4+ messages in thread
From: Hugh Sasse @ 2008-05-09 17:58 UTC (permalink / raw)
  To: Jaspreet Singh; +Cc: cygwin

On Fri, 9 May 2008, Jaspreet Singh wrote:

> ok Hugh Sasse
> 
> as you have saw what i have done. i understand everything you
> wrote as i am a programer like about using functions and grep.
> But, the problem is that i am a windows programer and do
> programing in Visual Basic, I have already compleated this
> useradd, usermod , userdel, etc Commands in VB.
> VB programs cant be distributed as it need licence from Microsoft.
> So, i was tring to do open source kinda thing.

Yes, I agree with your goals.  In VB you are probably way ahead of me.
> 
> Believe me i dont know anything about Perl. I was just tring to

It has been part of Perl's philosophy that beginners are welcome,
and beginner's code is not to be frowned upon.  My comments were
intended to be constructive, and help you progress in perl.  I wrote
them off-list so there was no possibility of you feeling criticised
in public, and I'm content that you replied to the list as I
specifically said.

> write a script for these commands and still tring as i have ported
> webmin and virtualmin to cygwin with all of the required modules
        [...]
> 
> so as i am tring if you can do what you just wrote to my sample perl script it will be really a great.
> 
> The big problem is user and group with same name with virtualization in passwd and group file. How to calculate that
> 
> The easiest way is create real user with "_usr" and real group with "_grp" at the end of the username and groupname in windows, then input in passwd and group file on cygwin without "_usr" and "_grp", with real UID and GID.

I can't put in the time to do this for you but you can extract
things from this, written for Solaris and no longer needed.

#!/usr/local/bin/perl -w

# Program to add users according to their name.


$group_to_add_to = 113; # The group to which we are
                        # adding users
$user_stem = "rx93";    # The start of the username

%gcos_by_name = ();
%name_by_gcos = ();

$final_uid = 0;
$final_username = "";

# First we need to get the information about users
# we already have.

sub init_passwords
{
   my($name,$passwd,$uid,$gid,
     $quota,$comment,$gcos,$dir,$shell);

   # You could do this with
   #   open(PASSWD, "</etc/passwd") || die "Can't open passwd for reading";
   #   while (<PASSWD>) { 
   #     ($name,$passwd,$uid,$gid, $gcos,$dir,$shell) = split(/:/); 
   #     #...
   #   }
   #   close(PASSWD);
   # or something.

   setpwent;
   while (($name,$passwd,$uid,$gid,
           $quota,$comment,$gcos,$dir,$shell) = getpwent) 
   {
      $gcos_by_name{$name} = $gcos;
      $name_by_gcos{$gcos} = $name;
      $final_uid = $uid if $group == $group_to_add_to;
      $final_username = $name if $group == $group_to_add_to;
   }
   endpwent;
}; # end init_passwords


# Then we need to continuously prompt for names,
sub get_users_name()
{
   my($title);
   my($first_name, $first_initial);
   my($last_name, $last_initial);
   my($middle_initials);
   my($username, $gcos);

   print "Enter new user's Title:";
   $title = <STDIN>;
   
   print "Enter First Name:";
   $first_name = <STDIN>;

   print "Enter (middle) Initials:";
   $middle_initials = <STDIN>;

   print "Enter Last Name:";
   $last_name = <STDIN>;

   # derive a new username for the user.
   $first_name =~ /(\w)\w+/;
   $first_initial = $1;

   $last_name =~ /(\w)\w+/;
   $last_initial = $1;

   $username = lc "$user_stem$first_initial$last_initial";

   # Check the username doesn't clash
   if (defined($gcos_by_name{$username}))
   {
      # If if does generate a unique name.
      $new_username = $username . "1";
      while (defined($gcos_by_name{$new_username}))
      {
         $new_username++;
      }
      $username = $new_username;
   }

   # The next thing to do is to construct the gcos
   # field for this user, 
   $gcos = "$first_name $last_name";

   # and make sure this does not
   # clash with one already there (John Smith...)
   if (defined($name_by_gcos{$gcos}))
   {
      $gcos = "$first_name $middle_initials $last_name";
   }

   if (defined($name_by_gcos{$gcos}))
   {
      print STDERR "Warning: $gcos is already used by $name_by_gcos{$gcos}\n";
   }
   else
   {
      $name_by_gcos{$gcos} = $username;
   }
   $gcos_by_name{$username} = $gcos;

   print "$gcos will have username $username\n";

   return($username,$gcos);
}; #end get_users_name


sub setup_account
{
   my($username, $gcos) = @_;
   # create a directory for the user

   my($uid) = getuid($username);
   my($gid) = getgid($username);

   mkdir("/home/$username",0755);
   chown $uid, $gid, "/home/$username";

   # install the appropriate files for them,

   foreach $file (".profile", ".cshrc", ".login")
   {
      system("cp /etc/skel/local$file /home/$username/$file");
      # and make sure they own the files.
      chown $uid, $gid, "/home/$username/$file";
   }
}; # end setup_account;
   

sub update_passwd
{
   my($username, $gcos) = @_;

   my($uid) = $final_uid++;

   $passwd_entry = "$username:x:$uid:$group_to_add_to:$gcos:/home/$username:/bin/csh\n";

   open(PASSWD, ">>/etc/passwd") or die "Unable to open /etc/passwd for appending";
   print PASSWD $passwd_entry;
   close(PASSWD);

   # Shadow entry  stuff deleted.
}

init_passwords

$finished = 0;
while(!$finished)
{
   ($name,$gcos) = &get_users_name;
   &update_passwd($name,$gcos);
   &setup_account($name,$gcos);
   print "Another? ";
   while(($ans = <STDIN>) =~ /^[yYnN]/)
   {
      print "Uh?  Yes or No. Another? ";
   };
   $finished = ($ans =~ /^y/i);
};

__END__
        HTH
        Hugh
        

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: cygwin perl useradd command
       [not found] <Pine.GSO.4.64.0805091314490.5627@brains.eng.cse.dmu.ac.uk>
@ 2008-05-09 15:45 ` Jaspreet Singh
  2008-05-09 17:58   ` Hugh Sasse
  2008-05-10 19:51 ` Jaspreet Singh
  1 sibling, 1 reply; 4+ messages in thread
From: Jaspreet Singh @ 2008-05-09 15:45 UTC (permalink / raw)
  To: cygwin

ok Hugh Sasse

as you have saw what i have done. i understand everything you wrote as i am a programer like about using functions and grep. But, the problem is that i am a windows programer and do programing in Visual Basic, I have already compleated this useradd, usermod , userdel, etc Commands in VB.
VB programs cant be distributed as it need licence from Microsoft. So, i was tring to do open source kinda thing.

Believe me i dont know anything about Perl. I was just tring to write a script for these commands and still tring as i have ported webmin and virtualmin to cygwin with all of the required modules for virtual server and administartion of system, the only command it requre is now thease useradd, userdel and so on, And quotaon, quotadel and so on. Even quota can work on cygwin as on windows with NTFS partition it has command "fsutil quota" to manupulate user quota on command line.

so as i am tring if you can do what you just wrote to my sample perl script it will be really a great.

The big problem is user and group with same name with virtualization in passwd and group file. How to calculate that

The easiest way is create real user with "_usr" and real group with "_grp" at the end of the username and groupname in windows, then input in passwd and group file on cygwin without "_usr" and "_grp", with real UID and GID.


      Meet people who discuss and share your passions. Go to http://in.promos.yahoo.com/groups/bestofyahoo/


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-05-10 14:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-09 13:29 cygwin perl useradd command Jaspreet Singh
     [not found] <Pine.GSO.4.64.0805091314490.5627@brains.eng.cse.dmu.ac.uk>
2008-05-09 15:45 ` Jaspreet Singh
2008-05-09 17:58   ` Hugh Sasse
2008-05-10 19:51 ` Jaspreet Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).