[linux] script question

Robin Battey zanfur at zanfur.com
Wed Mar 10 10:58:07 PST 2004


Looks like you used windows to edit the files, leaving a bunch of
carriage returns in them. Run them through dos2unix and then try again:

$ dos2unix test.txt
$ dos2unix <script filename here>

Windows text editors (well, most of them) have a \n\r (newline and
carriage return) at the end of every line, whereas most Unix programs
only use \n. To further complicate matters, Macs only use \r. In any
case, make sure you're just using \n when you're trying to do stuff in
Linux.

Cheers!
-robin

On Wed, Mar 10, 2004 at 10:10:11AM -0800, Tristan Burch wrote:

> I'm trying to write a script that will read the username and userid from a

> text file and then add that user to the machine with the specified id. I'm

> kinda new to scripting, so I'm not sure exactly what I'm doing wrong. Here's

> what I have:

>

> #!/bin/bash

>

>

>

> NEW_USERS="test.txt"

>

>

>

> cat ${NEW_USERS} | \

>

> while read USER ID

>

> do

>

> adduser -u $ID $USER

>

> echo Added User:$USER - ID:$ID

>

> done

>

>

>

> when I run it, I get this:

>

> 'dduser: invalid numeric argument `551

>

> Added User:tburch - ID:551

>

>

>

> I'm not sure why it's chopping off the "a" in adduser, but I think it has

> something to do with how the variables get evaluated (?). Any suggestions?

>

>

>

> Thanks,

>

>

>

> Tristan Burch

> <mailto:tburch at u.washington.edu> tburch at u.washington.edu

>

>

>


--
Robin Battey

90CF 2E8F 8A96 D0C0 09A2 9CFE C130 6CD4 6DC3 6DCF
http://www.zanfur.com/zanfur.pub
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 238 bytes
Desc: not available
URL: <http://mailman13.u.washington.edu/pipermail/linux/attachments/20040310/1c797f15/attachment.sig>


More information about the Linux mailing list