Issue in passing passwd to login into a sudo account


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Issue in passing passwd to login into a sudo account
# 1  
Old 03-05-2011
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,

Code:
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 same sudo account login... It's not working now and I'm getting below error,

My script:
===========


Code:
#!/bin/bash
CMD="sudo su - villin"
gzcat ~/passwd.gz | ${CMD} << eof1
sh New_report_dev.sh
eof1



Error:
======


Quote:
kinit(v5): Password incorrect while getting initial credentials
You did not kinit successfully.


Do I need to set any variable here to achieve this?
Can anyone please advice?


Regards,
VRN

---------- Post updated at 09:26 PM ---------- Previous update was at 08:03 PM ----------

Hello frnds,

I found the issue, but i need some more help...

Actually it's working for sometimes, nit working for sometimes...
But after logged into sudo account, the default shell is 'csh'. So after logged into this account, I'm trying to set some env variables. The syntax of setting variables and calling them inside csh is wrong...

Code:
#!/bin/bash
CMD="/usr/bin/sudo /bin/su - villin"
gzcat ~/code.gz | ${CMD} << eof1
echo "Logged into villin successfully"
#Once logged into this account, the default shell is 'csh' here.
set PATH1 = ~/pd/perl/prod/bin/perl
set PATH2 = ~/logs/temp
$argv[$PATH2] $argv[$PATH3]New_report_dev.pl
exit
eof1



It's unable to read those variables and the Perl script is not executing here...
Can anyone please have a look at the below my code and suggest on this?


Regards,
VRN
# 2  
Old 03-06-2011
I'm not sure but I think it's because your var CMD is set to a string
"/usr/bin/sudo /bin/su - villin" <---- this is a string not a command

try this:
Code:
CMD=`/usr/bin/sudo /bin/su -villin`

Using backticks instead of double quotes. I'm still quite the beginner but that's my best guess.
# 3  
Old 03-06-2011
HI,
Thank u vm for your reply..

Here the sudo command is working fine for sometimes...
The main issue in this script is: Once it's changed to sudo account 'villin', it's unable to set the variables 'PATH1 & PATH2'... because once the id is changed, it'll be in c shell.... And i dont have much idea abot setting up variables in cshell..

Can you/anyone please advice me on this?

regards,
VRN
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

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... (1 Reply)
Discussion started by: abhi_n123
1 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. AIX

User Account Login Login on your AIX server

I want to learn AIX. I would like to find someone who would be willing to give me a login to their AIX home lab server. My intent is to poke around and discover the similarities and differences of AIX compared to other *NIXs. I am a UNIX admin so I can think of what some immediate concerns may... (1 Reply)
Discussion started by: perl_in_my_shel
1 Replies

4. Red Hat

Sudo to execute script without passwd[solved]

Hi Hope someone can sched some light i'm trying to execute a script via sudo but i don't want to be prompted for a password when i run the script using sudo my sudo entry does work in that the script gets executed but i'm having to give a password, my current entry is given below user1 ... (0 Replies)
Discussion started by: duckeggs01
0 Replies

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

6. Shell Programming and Scripting

passing passwd to a command in a script

Hi All, I have a requirment.. I need to pass a registry password to a command.. Actually when the command executed in the script, it will return some warnings first, then after it'll ask password like below, $ cleartool rmtag -vob -all <vob_name> Warnings: ------------------ Registry... (3 Replies)
Discussion started by: raghu.iv85
3 Replies

7. Shell Programming and Scripting

Locking specific account without using passwd

Hey guys just wondering how i could lock a specific acount by prepending LK to the password field in the /etc/shadow file. it cannot be done through a command since the script gets called by a menu driven interface so i cant use "passwd". Is there a way where i can search for a specific account... (11 Replies)
Discussion started by: musicmancanora
11 Replies

8. Shell Programming and Scripting

Shellscript to Sudo other account

Hi, I have to write a shell script to sudo other account. Foreg, i am working in account ramdev1, i have a sudo access where through shell script i need to sudo another account ramdev2 and read a file "ram.inc" get those data and save it in a .txt file and return it? Since i am new to... (21 Replies)
Discussion started by: sachin.tendulka
21 Replies

9. UNIX for Dummies Questions & Answers

Setting an account to be a non-login account automatically?

Is there a way to easily change an account to be a non login account (NP in the shadow) file? I know I can just edit the file but that is not what we want to do. We use access control software and want to provide a way to set an account to be non-login using simple commands that can be mapped... (0 Replies)
Discussion started by: LordJezo
0 Replies

10. UNIX for Dummies Questions & Answers

Account creation Sudo enabled

Hi, how to create account with the following be cron enabled only accessible via sudo (1 Reply)
Discussion started by: vilves
1 Replies
Login or Register to Ask a Question