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.
Thread Tools Display Modes
Old 25th April 2008, 07: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

#   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
Old 25th April 2008, 21:32
till till is offline
Super Moderator
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 37,015
Thanks: 840
Thanked 5,652 Times in 4,461 Posts

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


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 13:19
Anything I can do against illegal login-requests? schmidtedv Installation/Configuration 17 7th November 2008 10:25
add web site serr57 Installation/Configuration 18 13th April 2008 12:40
Ruby / FastCGI Problem Chad Server Operation 1 8th March 2008 21:38
log files cruz Technical 3 15th May 2007 15:35

All times are GMT +2. The time now is 12:09.

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