Need help with script when trying to modify user


 
Thread Tools Search this Thread
Operating Systems Solaris Need help with script when trying to modify user
# 1  
Old 01-04-2010
Need help with script when trying to modify user

The script get a csv file with 2 colls for example:
123456,UNIX
963852,Microsoft

the script supose to put the number in the Description of the user in this case UNIX or Microsoft
the error i get is

does not exist.OR: UNIX
does not exist.OR: Microsoft

but the users exist so i do not understand
if i do
Code:
 usermod -c 123456 UNIX

it works
this is what i have for now:
Code:
n=`wc -l < users.csv`

i=1

while [ "$i" -le "$n" ]

do

line=`cat users.csv | head -$i | tail -1`

#echo $line

user=`echo $line | awk -F"," '{print $2}'`

ID=`echo $line | awk -F"," '{print $1}'`

usermod -c $ID $user

i=`expr $i + 1`

done

# 2  
Old 01-04-2010
Tools Two things to think about

1) Try not to use variables like user and ID as they may have other meanings. For instance on my system the id command will tell me somehting about myself.
2) Why not echo sel_usr and sel_id variables after you set them to make sure your assignments are ok?
# 3  
Old 01-04-2010
Ok i will check it but just that you know

when i print out the variables like this

echo $ID $user
it prints out ok the ID and the User

but when i print out the
echo $user $ID
it does not print out the users just the ID

somthing wiered
# 4  
Old 01-05-2010
Your script is too complex, try this.


Code:
 
sed 's/,/ /' user.csv |  while read id user; do usermod -c  $id $user ; done

# 5  
Old 01-05-2010
thanks but

where should i but put the line you wrote?

i tried just to run the ROW you wrote in the shell Console but it gives me somthing like
"while: Expression syntax"
# 6  
Old 01-05-2010
Or even slightly simpler:
Code:
IFS="," ; while read id user ; do echo usermod -c $id $user ; done < users.csv



---------- Post updated at 07:40 ---------- Previous update was at 07:37 ----------

Quote:
Originally Posted by shatztal
where should i but put the line you wrote?
It would replace your whole script.
Quote:
i tried just to run the ROW you wrote in the shell Console but it gives me somthing like
"while: Expression syntax"
Refrain from using csh/tcsh and use instead a POSIX compliant shell like ksh or bash.
# 7  
Old 01-05-2010
i still get an error

i changed the echo command and removew the echo or else i just got the ouput of the command

usermod -c 123456 UNIX
usermod -c 123456 Microsoft


after that the command you gave me printed out the same error of :

does not exist.OR: UNIX
does not exist.OR: Microsoft
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Modify python script

How can I modify this so it uses Seamonkey and goes to Yahoo Advanced Web Search #!/usr/bin/python3 import os import urllib google = os.popen('zenity --entry --text="Enter what you want to google: " --title="google.py"').read() google = urllib.quote(google) os.system('firefox... (8 Replies)
Discussion started by: drew77
8 Replies

2. Solaris

Grant unprivileged user rights to see the output of echo|format but not modify disks

anyone have any idea how do to this with auth_attr? I suspect if I grant him solaris.device.:RO::Device Allocation::help=DevAllocHeader.html that will work but I'm unsure. Just looking for a second opinion. (10 Replies)
Discussion started by: os2mac
10 Replies

3. Shell Programming and Scripting

Get username of last user to modify a file

Possible to get this? Thanks (2 Replies)
Discussion started by: stevensw
2 Replies

4. Shell Programming and Scripting

how can I modify this script.

hello forum members, I have a script which is used find the Uname and passwords and redirects into a output.txt file.I hardcoded a string "ciadev" but iwant search two more strings also "absdev" and "absprod" So modify this script please. I am lookinmg forward from you, please find the below... (2 Replies)
Discussion started by: rajkumar_g
2 Replies

5. Shell Programming and Scripting

Help in Shell scripting to modify the User Creation script in oracle database.

Hi, I have several users to create on my test Oracle database taking the scripts from the Production Oracle database. I have a separate text file where I have user-id and passwords maintained. I need help in writing a shell script to go thru the user creation scripts and replace VALUES... (1 Reply)
Discussion started by: rparavastu
1 Replies

6. Shell Programming and Scripting

Please help to modify my script

Hi, I have a script which connect to ATM's and pull two files from the ATM. The which i try to pull is like PIC20085200001*.JPG First 7 digit consist of year montn and date as well After todays execution i want to change the date to next date I add few lines in the script but it is not... (6 Replies)
Discussion started by: Renjesh
6 Replies

7. Shell Programming and Scripting

Modify Perl script to work with txt - Permissions script

Hi I have this code, and i want work with a ls -shalR output in .txt What i need read to do this?? Where start? #!/usr/bin/perl # Allrights- A perl tool for making backups of file permissions # Copyright (C) 2005 Norbert Klein <norbert@acodedb.com> # This program is free... (1 Reply)
Discussion started by: joangopan
1 Replies

8. UNIX for Dummies Questions & Answers

Modify user home dir

I created a new user and assigned a certain home dir to tis user. I've noticed that this home dir (/export/home/test) is already assigned to other users. I really want to create a dedicated home dir for the new user. Can anyone tell me how I can modify this user with a new homedir? Thx for... (4 Replies)
Discussion started by: kris_devis
4 Replies

9. UNIX for Dummies Questions & Answers

Modify Root user account ?

How can I modify Root account ? (I want to change the default shell after logging in) Thanks (3 Replies)
Discussion started by: hitlermom
3 Replies

10. UNIX for Dummies Questions & Answers

create or modify user account to have same access as root

Is there a way to create or better yet modify a user account so it has the same privs as root? (6 Replies)
Discussion started by: xadamz23
6 Replies
Login or Register to Ask a Question