Passing password to sudo login


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Passing password to sudo login
# 1  
Old 12-13-2012
Passing password to sudo login

Hi All,

I am trying use the below su command to execute a shell script using different user.
Caould some one please help me out as to how to pass the pass the password when prompted or is there any way to execute the shell script using other user.
I have had look at the other posts in forum but is not working correctly.

Please help..

Code:
#!/usr/bin/ksh
su - cobr_ext -c /home/cobr_sftp/var/script/test_gpg.sh

# 2  
Old 12-13-2012
If you run the shell script as root.I think it may work.Because root can su to any other user.
But if you run that as a no-root user.I think you should add 'sudo' at the head of line2.At the same time,make sure you have the right to use 'sudo' as the no-root user.Please use command 'visudo' to edit the file /etc/sudoers.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Automating su ( sudo ) login

Hi, I am planning to automate a deployment process and the below are the steps Connect from windows to Unix server Login with user name : admin and password After logging in , switch user to root to get additional privileges Perform actions on files and directories post switching to... (3 Replies)
Discussion started by: venkidhadha
3 Replies

2. Shell Programming and Scripting

passing login details to htaccess login prompt

Hi, How i can pass the login details to the URL which is password protected with the htaccess using command line or script (perl,or shell,or php). Any help or hint appreciated. Thanks, SJ (4 Replies)
Discussion started by: SilvesterJ
4 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. UNIX for Dummies Questions & Answers

sudo login issue

I logged in through ssh, but can't re-login as root. sudo login Arch login: root Password: Login incorrect Arch login: But I am sure my password is right. Why? But on local tty1, this works. (2 Replies)
Discussion started by: vistastar
2 Replies

5. Shell Programming and Scripting

Issue in passing passwd to login into a sudo account

Hi Gurus, I have small issue... I used to pass the passwd for sudo commands like below, gzcat ~/passwd.gz | sudo su - <villin> >> eof ------ ----- ------ eof And it was able to login into "villin" sudo account successfully. But now, I'm using the same in another script for the... (2 Replies)
Discussion started by: raghu.iv85
2 Replies

6. UNIX for Advanced & Expert Users

ssh and sudo login

Hi, I am trying to execute some command, via ssh and sudo. Here is what i want to do. ssh localhost | sudo su - ldaprole | ls -ltrh However, this command gives me listing of my home directory, and not of ldaprole. If I logic directly, when i perform sudo su - ldaprole, it... (5 Replies)
Discussion started by: john_prince
5 Replies

7. Shell Programming and Scripting

SSH Login by passing password.

ssh/sftp login by passing password , is it possible.Don't want to expect. (1 Reply)
Discussion started by: dinjo_jo
1 Replies

8. Solaris

SSH Password-less login fails on password expiry.

Hi Gurus I have a few Sol 5.9 servers and i have enabled password less authentication between them for my user ID. Often i have found that when my password has expired,the login fails. Resetting my password reenables the keys. Do i need to do something to avoid this scenario or is this... (2 Replies)
Discussion started by: Renjesh
2 Replies

9. Shell Programming and Scripting

Passing a variable to sudo sed command

hi, dataParse(){ line="$@" name="cat /etc/passwd | grep "$line": | cut -f6 -d':'" eval $name > sam.txt 2>&1 sudo -u $line sed -n 's/data-1/&/p' $name/test.xml >> sam1.txt } Here i getting the homedir of the accounts and is set in name variable.which returns "/home/raju" which i... (3 Replies)
Discussion started by: sachin.tendulka
3 Replies
Login or Register to Ask a Question