Visit Our UNIX and Linux User Community


Shell Program that prompts for user Id


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Program that prompts for user Id
# 1  
Old 10-23-2007
Bug Shell Program that prompts for user Id

Hi

I have a question that after trying tirelessly I cant solve. I'm not great wth UNIX and wonder if anyone could help. I have to create a shell program using functions that prompts for a user ID. I must then verify that the user Id corresponds to an account on the system. If a legal user Id is provided then the pathname of the user's home directory must be displayed. If a user ID that is not recognised is entered an error message must be displayed. Any possible solution would gbe greatly appreciated.

Thanks in advance!
# 2  
Old 10-23-2007
This sounds like homework to me. Why must you use functions for example?
# 3  
Old 10-23-2007
It is not homework but a sample I was given. I dont necessarily have to do it but I would like to see how it is done so I can look at it and try and understand how it works. If anyone has any kind of help at all it would be greatly appreciated. As for the use of functions I'm not sure why they are used. Anyone with help please let me know. Thanks..

Last edited by mmg2711; 10-23-2007 at 12:35 PM..
# 4  
Old 10-23-2007
To get user input use the built-in ksh command read. See a ksh manual about how read works.

After having got the input search through /etc/passwd, there are all the users of this system along with their UIDs. Have a look at this file (it is readable for everybody) and you will surely find out how it is organized. Use the command grep (man grep) to search this file with the given input.

bakunin
# 5  
Old 10-24-2007
Hey does anyone have any sample code on how best to do this. im sure there is an if else statement in it.
# 6  
Old 10-24-2007
Quote:
Originally Posted by mmg2711
im sure there is an if else statement in it.
You have just forfeited the last ounce of good will here. If you do not want to do your work yourself, why should we do your work besides our own? The statement i quoted shows, that you are just making wild guesses instead of looking into manpages, educating and informing yourself or otherwise are unwilling to put any effort in finding a solution apart from writing one-liners here supposed to make us providing you with a script you could then pass on as your own.

The bottom line is: this is despicable.

bakunin
# 7  
Old 10-24-2007
Despicable?? I thought these forums were meant to help. All I want is a possoble solution. I'm not here to offend anyone.

Previous Thread | Next Thread
Test Your Knowledge in Computers #795
Difficulty: Easy
10 has three prime factors 1, 2 and 5.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sqlldr call via shell script prompts error

Good morning, I'm attempting to call sqlldr via shell script and it is prompting endIf is unec #!/bin/sh cd /tmp/v_tst FILENAME_WANTED=`date +"HourlyData_%Y%m%d_%H00.txt"` echo "FILENAME_WANTED = ${FILENAME_WANTED}" LIST_OF_FILES=`ls -rt HourlyData*.txt |tail -1` LIST_OF_FILES=`basename... (4 Replies)
Discussion started by: V1l1h1
4 Replies

2. Shell Programming and Scripting

Scrolling through text while interacting with program prompts

Hi all, I am trying write a shell script to automate the installation of a program, but during the process of the installation, the installation program requires the user to scroll through 10 pages of a license agreement. Since this is coming from stdout and is not a prompt, I am unable to send... (4 Replies)
Discussion started by: nanlee
4 Replies

3. Shell Programming and Scripting

how to run a command line with another user without prompts for password

Hi, I'm writing a script, in the script I need to use tcpdump to capture some packets however it needs root priviledge my computer is configured by school and I have no real root priviledge so I can't use sudo on my computer,like Code: sudo tcpdump ...... I have to use a limited... (1 Reply)
Discussion started by: esolve
1 Replies

4. Shell Programming and Scripting

Bash script to start program and answer prompts?

I'm trying to write a script the simplifies the execution of a program: After starting the program (sh ~/.mfix/model/make_mfix) I am prompted four times for options: Do you need SMP version? (y/n) Do you need DMP version? (y/n) Do you need debug version? (y/n) Force re-compilation of... (2 Replies)
Discussion started by: lanew
2 Replies

5. Shell Programming and Scripting

script prompts the user to enter four lines.

The script prompts the user to enter four lines. (1 Reply)
Discussion started by: polineni
1 Replies

6. Shell Programming and Scripting

Help to hide shell terminal and run prompt program after ssh login for specified user

Hey guys, I have some task from my office to lock user on the specified directory after the user logged on using ssh. And then run prompt program to fill the required information. Yeah, just like an ATM system. My question: How could I do those?? AFAIK I have to edit the ~./bashrc. But the... (1 Reply)
Discussion started by: franzramadhan
1 Replies

7. UNIX for Advanced & Expert Users

Advantage of executing program in user shell?

Hi, I'm curious about the advantage of forking and executing a program in a user shell as opposed to forking and executing the program directly without the user shell. For example: why is it often like: SSHD->fork&exec(shell, sftp-server)->fork&exec(sftp-server) And Not like: ... (2 Replies)
Discussion started by: seeker333
2 Replies

8. UNIX for Dummies Questions & Answers

Shell Program that prompts for user Id

Hi I have a question that after trying tirelessly I cant solve. I'm not great wth UNIX and wonder if anyone could help. I have to create a shell program using functions that prompts for a user ID. I must then verify that the user Id corresponds to an account on the system. If a legal user Id is... (1 Reply)
Discussion started by: mmg2711
1 Replies

9. Shell Programming and Scripting

Shell script answer prompts?

Hi, I'm writing a script that calls a function to generate a certificate. In generating this certificate, I'm asked a series of questions. I was wondering, is there a way to pre-program my script to answer these questions in the same way all the time. I saw something like EOF>> y EOF ... (4 Replies)
Discussion started by: eltinator
4 Replies

10. Solaris

pkgadd pkgask still prompts for user input

I create a succesful pkgask 'response' file: pkgask -r xyz.pkg I then attempt to use the 'response' file with pkgadd: pkgadd -nr /home/user/response -d /home/user/xyz.pkg the prompts for user input still appear. I have also tried an 'admin' file but that still prompts for user input as... (1 Reply)
Discussion started by: prkfriryce
1 Replies

Featured Tech Videos