<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<TITLE>Message</TITLE>

<META content="MSHTML 6.00.2800.1400" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=978091521-29042004><FONT face=Arial color=#0000ff size=2>Try 
escaping the quotes with backslashes.  I have a script that does something 
similar....it first checks to make sure the user is a valid university 
account....here's my code.  It also prompts the user to enter a password 
(in a bash shell script):</FONT></SPAN></DIV>
<DIV><SPAN class=978091521-29042004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=978091521-29042004><FONT face=Arial color=#0000ff 
size=2>        print "Adding user 
$username...\n";<BR>        
`/usr/sbin/useradd "$username" -g users -c 
\"$realname\"`;<BR>        `passwd 
$username`;<BR></FONT></SPAN></DIV>
<DIV> </DIV>
<DIV> </DIV><!-- Converted from text/plain format -->
<P><FONT size=2>-----<BR>Ryan Golhar<BR>Computational Biologist<BR>The 
Informatics Institute at<BR>The University of Medicine & Dentistry of 
NJ<BR><BR>Phone: 973-972-5034<BR>Fax: 973-972-7412<BR>Email: 
golharam@umdnj.edu</FONT> </P>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
  <DIV></DIV>
  <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT 
  face=Tahoma size=2>-----Original Message-----<BR><B>From:</B> 
  redhat-list-bounces@redhat.com [mailto:redhat-list-bounces@redhat.com] <B>On 
  Behalf Of </B>Johnson, Shaunn<BR><B>Sent:</B> Thursday, April 29, 2004 4:45 
  PM<BR><B>To:</B> 'General Red Hat Linux discussion list'<BR><B>Subject:</B> 
  rebuilding accounts<BR><BR></FONT></DIV>
  <P><FONT size=2>Howdy:</FONT> </P>
  <P><FONT size=2>Running RHEL v.3.</FONT> </P>
  <P><FONT size=2>I'm moving user home directories to the new </FONT><BR><FONT 
  size=2>server and I need to add them to passwd / shadow</FONT> <BR><FONT 
  size=2>and group files.  I make a script like so:</FONT> </P>
  <P><FONT size=2>[snip]</FONT> <BR><FONT size=2>#!/bin/bash -x</FONT> </P>
  <P><FONT size=2>echo "building users account"</FONT> <BR><FONT size=2>echo " 
  "</FONT> </P>
  <P><FONT size=2>for i in `cat /tmp/lusers.txt`</FONT> <BR><FONT 
  size=2>do</FONT> <BR><FONT size=2>echo "making account for the user: 
  $i"</FONT> <BR><FONT size=2>echo " "</FONT> <BR><FONT size=2>/usr/sbin/useradd 
  -d /opt/home/$i -g users -M -p $i -s /bin/bash $i</FONT> <BR><FONT 
  size=2>done</FONT> <BR><FONT size=2>[/snip]</FONT> </P>
  <P><FONT size=2>The when I try to su - <user>, I get 'su: incorrect 
  password'.</FONT> <BR><FONT size=2>(note: I did this as a non-root user). I 
  thought that </FONT><BR><FONT size=2>maybe I should use single or double 
  quotes when putting </FONT><BR><FONT size=2>the password on the line, but the 
  errors are always the same.</FONT> </P>
  <P><FONT size=2>Question:  With useradd, is there a way to prompt 
  users</FONT> <BR><FONT size=2>for a new password upon login?  Otherwise, 
  I will have</FONT> <BR><FONT size=2>to write some one-liner to use 'passwd' to 
  generate</FONT> <BR><FONT size=2>default passwords.</FONT> </P>
  <P><FONT size=2>Thanks!</FONT> </P>
  <P><FONT size=2>-X</FONT> </P></BLOCKQUOTE></BODY></HTML>