PDA

View Full Version : user input with shell script



e24ohm
January 21st, 2010, 08:17 PM
User Input

Folks I am trying to develop a script, which will map a windows network share and prompt the user for their credentials.

I use the following code

#!/bin/bash
Mount –t smbfs //servername/sharename /mnt/mountdirectory –o username=windows username,password=windowspassowrd

How do I get my script to prompt the user for ‘windowsusername’ and ‘windowspassword’

Trumpen
January 21st, 2010, 08:51 PM
With read:


read -p "windows user: " winuser
read -s -p "windows passwd: " winpassword

mount –t smbfs //servername/sharename /mnt/mountdirectory –o username="$winuser",password="$winpassword"

Use "help read" for more info on read command.

smo0th
January 21st, 2010, 09:30 PM
cool =)

e24ohm
January 21st, 2010, 10:36 PM
With read:


read -p "windows user: " winuser
read -s -p "windows passwd: " winpassword

mount –t smbfs //servername/sharename /mnt/mountdirectory –o username="$winuser",password="$winpassword"

Use "help read" for more info on read command.

thanks - looking at it right now.