su option is not fetching the password


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users su option is not fetching the password
# 8  
Old 08-28-2012
Quote:
Originally Posted by Corona688
Another way would be using the sudo utility, which can be configured to allow one user to do one specific thing as another user. This would be better than installing a third-party brute-forcing utility to inject insecure plaintext passwords into an otherwise secure login system.
This +1 - It looks like sudo is exactly what you need for this task.

But an alternative might be to dabble with setuid instead. Extremely bad idea to do this with scripts as you can trick the OS into running arbitrary code that way, but with code that's not interpreted at runtime (ie compiled code) it works a treat.
This User Gave Thanks to Smiling Dragon For This Post:
# 9  
Old 08-29-2012
Can anyone explain me how to use sudo option with example?

---------- Post updated 08-29-12 at 01:49 AM ---------- Previous update was 08-28-12 at 11:10 PM ----------

[FONT=Courier New]
After doing su, my script get inputs from user. That was the reason for problem. Now i updated script to get input from separate function and then called in su.

It works.



Code:

Code:
function ABC
{
       echo "cp -p $spath/$ename $dpath/$ename"
       echo "chmod 774 $dpath/$ename"
}
echo      "Do you want to initiate the process ${bold}(Y/N?)${offbold}"
read inp
if [ $inp == "Y" -o $inp == "y" ] ;
then
............................
............................
............................
echo " Does this involves any other files? ${bold}(Y/N?)${offbold}"
read inp
    while [ $inp == "Y" -o $inp == "y" ] ;
       do
        echo "Enter Element Name:"
       read ename
       echo "Enter Element Source path:"
       read spath
       echo "Enter Element Destination path:"
       read dpath
   
    echo "***************************** "
    echo " Enter the abcuser password "
    echo "***************************** "
      (
       ABC
      ) | su abcuser
 echo "Do you have any other elements?${bold}(Y/N?)${offbold}"
       read inp
       done
  echo "Program has been executed."

---------- Post updated at 01:49 AM ---------- Previous update was at 01:49 AM ----------


After doing su, my script get inputs from user. That was the reason for problem. Now i updated script to get input from separate function and then called in su.

It works.



Code:

Code:
function ABC
{
       echo "cp -p $spath/$ename $dpath/$ename"
       echo "chmod 774 $dpath/$ename"
}
echo      "Do you want to initiate the process ${bold}(Y/N?)${offbold}"
read inp
if [ $inp == "Y" -o $inp == "y" ] ;
then
............................
............................
............................
echo " Does this involves any other files? ${bold}(Y/N?)${offbold}"
read inp
    while [ $inp == "Y" -o $inp == "y" ] ;
       do
        echo "Enter Element Name:"
       read ename
       echo "Enter Element Source path:"
       read spath
       echo "Enter Element Destination path:"
       read dpath
   
    echo "***************************** "
    echo " Enter the abcuser password "
    echo "***************************** "
      (
       ABC
      ) | su abcuser
 echo "Do you have any other elements?${bold}(Y/N?)${offbold}"
       read inp
       done
  echo "Program has been executed."

Thanks everyone

Last edited by Corona688; 08-29-2012 at 12:18 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Forum Support Area for Unregistered Users & Account Problems

Password sent via reset password email is 'weak' and won't allow me to change my password

I was unable to login and so used the "Forgotten Password' process. I was sent a NEWLY-PROVIDED password and a link through which my password could be changed. The NEWLY-PROVIDED password allowed me to login. Following the provided link I attempted to update my password to one of my own... (1 Reply)
Discussion started by: Rich Marton
1 Replies

2. Shell Programming and Scripting

Fetching timestamps from the logs.

Dear Experts, I need some help to get the time stamps from the Unix logs. Basically I am want to analyze which step is taking more time. Please give me some inputs. Thanks a lot for your help. I have got different codes for each for phase as we can see in the logs 00002 – UPDT Starting... (5 Replies)
Discussion started by: srikanth38
5 Replies

3. Shell Programming and Scripting

Notable to use password option in zip command

zip -P abc -r FBE_SalesRepAccount_20170913125741.zip FBE_SalesRepAccount_20170913125741.txt zip error: Invalid command arguments (encryption not supported) zip -v Copyright (C) 1990-1999 Info-ZIP Type 'zip "-L"' for software license. This is Zip 2.3 (November 29th 1999), by Info-ZIP.... (1 Reply)
Discussion started by: alokjyotibal
1 Replies

4. Solaris

Unrecognized option: sparc-sun-Solaris2.10/bin/as: unrecognized option `-m32'

Hi, I installed some packages required by an app built with python. But when I try python setup.py install, I get the following error: /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.2.0/../../../../sparc-sun-solaris2.10/bin/as: unrecognized option `-m32' Could anyone tell me what's wrong... (4 Replies)
Discussion started by: Kimkun
4 Replies

5. Shell Programming and Scripting

Fetching data from file

Hi All, I'm facing issue while using script. Chk_Etl_Status=`cat /dstage/questnet/qnetdv/input/Etl_Status.dat|cut -d"," -f1` echo Chk_Etl_Status=$Chk_Etl_Status above result is giving me sometime value as 1 and sometime error message as Chk_Etl_Status= dsjoblaunch.sh: test: Specify a... (5 Replies)
Discussion started by: Amit786
5 Replies

6. Shell Programming and Scripting

Fetching the string using different patterns

HI, Please help me with the following problem: I have an xml file with the following lines <NameValuePair> <name>SharedResources/JDBC/Admin/password</name> <value>rjmadmin</value> </NameValuePair> <NameValuePair> ... (4 Replies)
Discussion started by: tejastrikez
4 Replies

7. Shell Programming and Scripting

recently introduced to the newer option for find...does an older option exist?

To find all the files in your home directory that have been edited in some way since the last tar file, use this command: find . -newer backup.tar.gz Is anyone familiar with an older solution? looking to identify files older then 15mins across several directories. thanks, manny (2 Replies)
Discussion started by: mr_manny
2 Replies

8. Shell Programming and Scripting

option followed by : taking next option if argument missing with getopts

Hi all, I am parsing command line options using getopts. The problem is that mandatory argument options following ":" is taking next option as argument if it is not followed by any argument. Below is the script: while getopts :hd:t:s:l:p:f: opt do case "$opt" in -h|-\?)... (2 Replies)
Discussion started by: gurukottur
2 Replies

9. UNIX for Dummies Questions & Answers

No Password - - Setuid Only Option in Solaris 10

In Solaris 9, when I built users, there was an option for No Password -- Setuid Only. Now that I'm using Solaris 10, I no longer can find that option. Is there an equivalent option of No Password --Setuid Only in Solaris 10? Thanks, LeonD (1 Reply)
Discussion started by: leond
1 Replies
Login or Register to Ask a Question