Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 25th April 2008, 06:05
jack777 jack777 is offline
Junior Member
 
Join Date: Apr 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default su from normal user in scripts

Got a cron to run everyday under my user. this cronjob runs a script from my /home/jack/scripts/run.sh

Code:
clear
#
#   su to root and run a script, return with result
#   su -
#   passwd
#   run /getfile.sh
#   return with result 
#   the result will copy 2 files from /prod/app/logs/ and throws to my /home/jack/scripts/file1.txt and file2.txt
#
awk -F" "  '$5==0 && $3=="ServerA"{print $1}'  file1.txt file2.txt | sort -r | head -1 > output.txt
uuencode output.txt output.txt | mailx -s "Todays Server ErrorLog Reprot" xxx@xxx.com
I am having the root password. Need to know how to su from normal user, run script which has root privileges, logout from user with result to my user and continue the next sequence of my script.

All the above steps inside # remark statements needs proper code.

Thanks in advance
Reply With Quote
Sponsored Links
  #2  
Old 25th April 2008, 20:32
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,461
Thanks: 813
Thanked 5,240 Times in 4,108 Posts
 
Default

Have a look at the sudo command instead of su and the sudoers file. It allows you to execute a program or script under different priveliges.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Statistic not working mzo Installation/Configuration 49 20th April 2011 12:19
Anything I can do against illegal login-requests? schmidtedv Installation/Configuration 17 7th November 2008 09:25
add web site serr57 Installation/Configuration 18 13th April 2008 11:40
Ruby / FastCGI Problem Chad Server Operation 1 8th March 2008 20:38
log files cruz Technical 3 15th May 2007 14:35


All times are GMT +2. The time now is 21:10.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.