[sudo-users] Unable to change user in script

Aaron Spangler as at insight.rr.com
Thu Aug 5 18:18:47 EDT 2004


If I look at this script a little more closely, it looks as though sudo 
receives three lines.  The first line is the blank line before the echo 
line, the second is the echo line (including the word echo - probably 
not what you expected), and the third is another blank line.

Additionally, on many operating systems, sudo will read directly from 
the attached tty rather than from the redirectable stdin, so it probably 
won't work anyway.

You might talk with your security administrator who admins sudo and let 
them know that by requiring a password you will now begin hard-coding 
passwords in scripts unless they create an additional sudo role that 
allows access without a password.

 Hope that helps.

 -Aaron


Steffen.A.Johnson at wellsfargo.com wrote:

>I wrote the following ksh script to automatically change the user ID. 
>
> 
>
>#!/usr/bin/ksh
>
>PASSWD=test1
>
> 
>
>sudo -S su - otheruser << EOF
>
>   echo $PASSWD
>
>EOF 
>
> 
>
>When I run the script the passwd is passed to the su command properly but I
>get the following
>
>error message every time I run the program
>
> 
>
>Password:
>
>Sorry, try again.
>
>Password:
>
>sudo: 1 incorrect password attempt
>
> 
>
>I've checked that I am user "test1_user" and my passwd is test1.
>
> 
>
>Does anyone have any clues of why my script is failing?
>
> 
>
>TIA
>
> 
>
>Steffen
>
>____________________________________________________________ 
>sudo-users mailing list <sudo-users at sudo.ws>
>For list information, options, or to unsubscribe, visit:
>http://www.sudo.ws/mailman/listinfo/sudo-users
>  
>




More information about the sudo-users mailing list