Need to write a script user.sh that parses name & password


 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Need to write a script user.sh that parses name & password
# 1  
Old 04-08-2015
Need to write a script user.sh that parses name & password

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:
Write a script called user.sh that parses the name and password of given in a file (user.txt) and creates the user using first letter of first name followed by full last name. the password should be the third field.

Code:
First name   Last Name     Password
Johanna       Osbourne      TeSTiNg143


2. Relevant commands, code, scripts, algorithms:

Code:
First name   Last Name     Password
Johanna       Osbourne      TeSTiNg143


3. The attempts at a solution (include all code and scripts):
#!/bin/bash
Code:
  for row in `cat $1`
  do
      if [ $(id -u) -eq 0 ]; then
  

          username=${row%:*}
          password=${row#*:}
          #echo username
          #echo password


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
CUNY Medgar EVers, Brooklyn, ny, Prof. harris CIS 440

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

Last edited by Don Cragun; 04-09-2015 at 12:05 AM.. Reason: Add CODE and ICODE tags.
# 2  
Old 04-09-2015
We are not here to do your homework for you. We will be happy to help you figure out what needs to be fixed if you make an honest effort to do the work yourself and need some help figuring out why something isn't working.

Writing a for loop that has no end, containing an if statement that has no end, and splitting fields out of a line based on finding colon characters when there are no colon characters in your input file doesn't give us the impression that you have made an honest effort to solve your problem.

Please show us your entire script (using CODE tags), add comments to your code explaining what each statement is trying to do, show us any output you are getting from your script (using CODE tags), and show us the output you are trying to get from your sample input (using CODE tags).

Explain what you think is going wrong and show us where you are stuck.
This User Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

How to write a script to run without password on a batch of servers?

I need run a command such as ps -ef |grep xxx on a batch of servers, how to write a script to run it without password? don't need go in each server to check? Thanks (7 Replies)
Discussion started by: rainbow_bean
7 Replies

2. Shell Programming and Scripting

Write a scripts to kill idle user for 60 min. & email user list to admin in text file

Folks, I have written one script for following condition by referring some of online post in this forum. Please correct it if I'm missing something in it. (OS: AIX 5.3) List the idle user. (I used whoidle command to list first 15 user and get username, idle time, pid and login time).... (4 Replies)
Discussion started by: sumit30
4 Replies

3. Shell Programming and Scripting

PHP read large string & split in multidimensional arrays & assign fieldnames & write into MYSQL

Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP. I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Discussion started by: lowmaster
0 Replies

4. Shell Programming and Scripting

Problem - script that parses $date data...

This is probably archaic, but I'm new to unix and this is my first shell script. I'm writing this script to use in another script. All I am trying to do is make the parts of the output from date usable in my other script. I was wondering if you could stand looking at this and see if you notice... (8 Replies)
Discussion started by: Dalcron
8 Replies

5. Shell Programming and Scripting

Bash Script to Read & Write on different directories

Hi, root@server] df -h 121G 14G 101G 12% /home 147G 126G 14G 91% /backup We having our site files and images are storing in /backup/home/user/files/ through symbolic link created in /home directory pointing in /backup directory as following. root@server] cd /home... (1 Reply)
Discussion started by: mirfan
1 Replies

6. Shell Programming and Scripting

Need to write script to send an email for password reset.

Hi all, Please suggest I want to write a scritp which will send a email to my mail address before the time duration of the password reset, Should write mail stating that your password will expire in so and so days"" Rgds:b: Ann. (2 Replies)
Discussion started by: Haque123
2 Replies

7. UNIX for Dummies Questions & Answers

user & group read/write access question

folks; I created a new users on my SUSE box and i need to give this user/group a read write access to one specific folder. here's the details: - I created new user "funny" under group "users". - I need to give this user "funny" a read/write access to another directory that is owned by "root".... (3 Replies)
Discussion started by: Katkota
3 Replies

8. Shell Programming and Scripting

Is it possible to write a script to reset user's password?

Is there anyway that I can reset user's password using a script/ssh command? ie. emulate passwd command with a default password of abc123 or even null value? > ssh server1 pwdadm user1 < /dev/null or > ssh server1 passwd user1 < /dev/null neither worked for me.. but you know what I... (1 Reply)
Discussion started by: pdtak
1 Replies

9. UNIX for Dummies Questions & Answers

write a script & sum contents!PLEASE HELP

Hello everyone!! I have to write a script in unix that reads a file which is in the format: 1%blabla%30 2%blabla2%50 1%blabla3%40 2%blabla4%10 and produce the total quantities of 1 and 2: "1 = 70 2 = 60" I am taught basic unix commands, so I must keep it simple, how can i do this using... (7 Replies)
Discussion started by: questionmaker25
7 Replies

10. UNIX for Dummies Questions & Answers

How would I telnet & change user password automatically in a script

I would like to create a script that logs into a list of several servers 50+ and changes my password all at once. Every 60 days we are required to login to each system and change our passwords or else they expire and our login account is deleted. I have an idea on how I could do this but... (4 Replies)
Discussion started by: darthur
4 Replies
Login or Register to Ask a Question