How to give password at run time in a shell script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to give password at run time in a shell script?
# 1  
Old 05-15-2013
How to give password at run time in a shell script?

hi,

how can i pass a password automatically when a shell script is running.

i have shell script(runscript.sh) which call another shell script inside it as a different user.

runscript.sh contains

Code:
su - nemo -c "/bin/main_script.sh"

but when i execute "runscript.sh" it try to run main_script.sh and prompts for a password. so i have to give the password manually. is there a way so that the script automatically reads a password? or is there a way so it doesnot prompt for a password at all?
# 2  
Old 05-15-2013
sudo serves this purpose.
# 3  
Old 05-15-2013
how? please give some examples.. what option do i have to use with sudo?
# 4  
Old 05-15-2013
Your sysadmin would have to set that up.

There's also a possibility of using expect, if you don't mind having your password stored in plain text.

Expect Thread
# 5  
Old 05-15-2013
idnt have expect and spawn command installed in putty. is there a way in which i can i can pass the password in the same line as

Code:
su - nemo <password>

# 6  
Old 05-15-2013
No. .
# 7  
Old 05-15-2013
is it possible to use expect command without the spawn command.? if it is possible then how?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell Script to run in given time

Hi All, Would like to write a Script which will run between 11am to 3 pm and send the results to output.txt. Please suggest. (2 Replies)
Discussion started by: vasuvv
2 Replies

2. Shell Programming and Scripting

Capture run time of python script executed inside shell script

I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies

3. Shell Programming and Scripting

Run a shell script on all 15 servers at the same time?

We have 15 servers. Hostnames for these 15 servers are stored in a text files and loop through each server to connect to the remote server and run a command, but this loop process runs the command one after another. However, the requirement is to run the same command on all 15 servers at the same... (10 Replies)
Discussion started by: laknar
10 Replies

4. Shell Programming and Scripting

How to run sftp in shell script without prompting for password?

Hi, Can anyone tell me how to pass password in a shell script for sftp so that i can run it in background without user entering the password? I used a expect script but it timesout after some time and the process remains incomplete at the end. Can anyone suggest any other idea? Will the... (3 Replies)
Discussion started by: Little
3 Replies

5. Shell Programming and Scripting

How to prvenent giving password run time in schell scripting?

Hi I'm copying around 20 vi files from solaris server-A to server-B using 'scp' command.I have included all 20 scp commands in one shell script. Proplem is, while executing each scp command its prompting for my NIS password of server A. Please see below How to get rid of password prompt.??? (1 Reply)
Discussion started by: buzzme
1 Replies

6. Shell Programming and Scripting

How to give full access to output files created by .sh script run via crontab?

Hi Expert, I have a .sh script in my home/new_dir/script.sh This script creates number of output files at home/new_dir/email, home/new_dir/logs dir. I am running this script using crontab (owner root). Now this output files are getting created with rw-r----- 1 root root So if i... (2 Replies)
Discussion started by: Jeet1982
2 Replies

7. UNIX for Dummies Questions & Answers

For SFTP connection - How to give password in UNIX Script (ksh)

Hi, I am not able to give the password in Unix script for SFTP connection. When I am trying to manully SFTP command for accessing the server , it asking for pwd and I could provide the pwd but I am not getting how to provide the pwd inside the Unix script. sftp -v user@xyz.com. ... (4 Replies)
Discussion started by: Vineeta Nigam
4 Replies

8. Shell Programming and Scripting

Connect Oracle using shell script at run time

Hi all, I am a newbie.....am jus trying to connect to oracle thro a script, but not thro giving the username/password@server_name directly like `$ORACLE_HOME/bin/sqlplus username/password@server_name In the above line, once it is connected to Oracle, it shud ask me the username and password... (4 Replies)
Discussion started by: kritibalu
4 Replies

9. Shell Programming and Scripting

Shell script to find the run time based on log entries?

Shell script to find the run time based on log entries? Below is the log files content updated when the script test.sh runs. I would like to calculte the difference between first update time stamp and last update time stamp to find the run time of the script. The below log file shows the first... (1 Reply)
Discussion started by: mailtopranesh
1 Replies

10. Shell Programming and Scripting

how to give sftp a password in a shell scripit

I want to write an sftp script, but I can't put ssh keys on my destination. Is it possible to pass sftp a password inside a script? I know that the -b option makes sftp use a file for params. Can the password go in such a file? How can I do this? Thanks in advance (3 Replies)
Discussion started by: kskywr
3 Replies
Login or Register to Ask a Question