The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 01-22-2008
dave123 dave123 is offline
Registered User
 

Join Date: Dec 2007
Posts: 45
Thank you for you reply, but i just cant get it to work, sudo is out of the question as
there is no sudo set up
if i run below as root it prints hello, but if i run as non root it will ask for password then, nothing, what am i doing wrong plse,

#!/bin/bash


if [ $(whoami) = "root" ]
then
echo "hello"
else
su root -c echo "hello"
fi
Reply With Quote