scripting password prompts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting scripting password prompts
# 1  
Old 03-21-2005
scripting password prompts

Hi there

Probably a really simple question but I am writing an install script and at certain stages of the install (ie creating a table in mysql) the system prompts for you to enter a password, I was wondering, how do I script this input so that the install doesnt keep stopping for manual intervention??,


thanks and regards
Gary
# 2  
Old 03-21-2005
Try something like this...

#! /usr/bin/ksh

print -n "Enter password - "
stty -echo
read PASSWORD
stty echo
print

Then just use $PASSWORD where you need it.
# 3  
Old 03-21-2005
Thanks Perderabo, its actually the other way round tho, i dont want to read the password, I want to write it ! for example my script issues the command ..


Code:
mysql -u root -p test

but before my script can move onto the next line , mysql pops up with an "enter password:" I would like to get my script to enter the password in for me (automatically answering mysql's authentication request)

I hope this clarifies
# 4  
Old 03-21-2005
In this case I think you can use a here file, to do that.

Or for password prompts in general look into using expect, it's the simplest way to do this.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash scripting mask password from ps

Hi All, I have a script, which prompts me for my password input, then it passes that password onto an argument for another script which is then passed onto an expect script which automates my logins to a bunch of servers to execute my commands. example. script A - request for password,... (7 Replies)
Discussion started by: aixkidbee
7 Replies

2. 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

3. Shell Programming and Scripting

ssh foo.com sudo command - Prompts for sudo password as visible text. Help?

I am writing a BASH script to update a webserver and then restart Apache. It looks basically like this: #!/bin/bash rsync /path/on/local/machine/ foo.com:path/on/remote/machine/ ssh foo.com sudo /etc/init.d/apache2 reloadrsync and ssh don't prompt for a password, because I have DSA encryption... (9 Replies)
Discussion started by: fluoborate
9 Replies

4. Shell Programming and Scripting

Expect scripting not seeing the screen prompts.

Someone recommended using an expect script for an issue I was having so I tried writing one but of the 3 expected prompts on the screen, it only see responds to the first one. The code is: ==================================== #!/usr/local/bin/expect -f spawn /usr/local/bin/rcs -u1.1 xyz.fmb... (1 Reply)
Discussion started by: pjones006
1 Replies

5. Shell Programming and Scripting

Scripting help/advise on hiding/masking username/password

Hi, I currently have a UNIX script with a function that uses a username and password to connect to the database, retrieve some information and then exit. At the moment, am getting the username and password from a hidden plain text file and permission set to -r--------, i.e. read only to who... (1 Reply)
Discussion started by: newbie_01
1 Replies

6. Shell Programming and Scripting

Scripting password changes.

Hello, I am looking for a way to login to multiple machines and do things such as create users, reset root passwords etc non interactively. The problem with the passwords is that all machines use ssh, dont allow root login, require to login as a normal user, su to root then change the root... (1 Reply)
Discussion started by: Actuator
1 Replies

7. Red Hat

SSH Prompts for Password After Keys Setup Successfully

I setup the keys between 2 servers, but my user account has no password specified for it (never set one up on the account for security reasons). When I try to SSH to the server, SSH prompts for a password that doesn't exist (so I can never connect successfully). Note: 'passwd -d Rynok' removes... (3 Replies)
Discussion started by: Rynok
3 Replies

8. Shell Programming and Scripting

scp scripting without asking password

I like to copy a file from one server server1 from path path1 to another server server2 to path path2. User logging in both the servers are same say user1 I tried to use ssh to generate public/private key pairs and then copy without prompting for password. These are the steps i followed ... (5 Replies)
Discussion started by: jwala
5 Replies

9. UNIX for Advanced & Expert Users

SSH prompts password for non identical users

host1 & host2 : Solaris 10 - SPARC server From host1 able to ssh to host2 as same user with out password prompt. But, when ssh to different user in host2, it prompts for password DETAILS ======= In host1: 1) logged as root 2) ssh-keygen -t dsa -b 1024 (no pass phrase) 3)... (5 Replies)
Discussion started by: vjkatsun
5 Replies

10. UNIX for Advanced & Expert Users

password prompts

I would like to log all the commands that are entered on an ssh client. I can do this successfully, however, I dont want to log user logins and passwords. Is there any way to identify passwords and avoid them? For example, I can look for a string 'password:' and ignore everything until a nl/cr. Is... (2 Replies)
Discussion started by: balag
2 Replies
Login or Register to Ask a Question