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
# 15  
Old 10-25-2007
To add further, check the second last column of /etc/passwd file.

To know more, learn how information in /etc/passswd file is organized.
# 16  
Old 10-25-2007
I know why $HOME is always printing the same because this is the home directory I am in. In this case would I need to cd(change directory) into the directory of the username that was entered? Thanks!
# 17  
Old 10-25-2007
Originally Posted by mmg2711
Thanks i got it workin with functions but I 've got one problem. If the user Id is on the system it always prints the home directory of the person that is currently logged on. I want to print the home directory of the user that has been input.

eg. my problem is "Please enter the username: michael
/home/michael "

"Please enter the username: john
/home/michael "

What I want to do in this case is print /home/john regardless if I'm logged in as michael. I know its something simple. Can anyone provide the line of code that would do this?

Yeah, I wasnt thinking. Instead of the echoing $HOME try
grep $username /etc/passwd | awk 'BEGIN {FS="[:]"} { print $6 }'

Login or Register to Ask a Question

Previous Thread | Next Thread

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
Login or Register to Ask a Question