The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem with csh script rahulrathod Shell Programming and Scripting 4 02-21-2008 12:38 PM
script problem tdavenpo Shell Programming and Scripting 3 01-04-2006 04:07 PM
Problem starting a script from a 'main'-script Rakker UNIX for Dummies Questions & Answers 3 06-28-2005 09:12 AM
problem with a script Lestat Shell Programming and Scripting 4 06-13-2005 01:30 PM
problem with ftp script...please help vancouver_joe UNIX for Advanced & Expert Users 2 11-22-2001 07:47 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-02-2006
Terrible
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Help. Script problem

hey guys. i have a bunch of programs in a script that needs to run as root and the rest as another user, we'll call him gabriel.

now, in this script, i want to run the first few lines as root. now, how do i, after running as root, tell the script to run the remaining lines as the user gabriel?


the script is set up a lil something like this. and this is just an example


who
uptime
vmstat -s 2 4
su - gabriel <=== is this the right way to tell the script to run the below commands as user gabriel?
ls -l /var/tmp
cat /var/tmp/getlost
  #2 (permalink)  
Old 07-02-2006
Hitori's Avatar
Hitori Hitori is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2006
Posts: 360
The problem is that you remain logged in as gabriel when script is done.
Better use
sudo -u gabriel \
ls -l /var/tmp;\
cat /var/tmp/getlost
  #3 (permalink)  
Old 07-02-2006
Terrible
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Quote:
Originally Posted by Hitori
The problem is that you remain logged in as gabriel when script is done.
Better use
sudo -u gabriel \
ls -l /var/tmp;\
cat /var/tmp/getlost
keep in mind all of this runs in a file. i'm not running them from the command line.

so basically your saying the below will work? (keep in mind, this is all running from a file, not the command line)


who
uptime
vmstat -s 2 4
sudo -u gabriel \
ls -l /var/tmp;\
cat /var/tmp/getlost
  #4 (permalink)  
Old 07-02-2006
Hitori's Avatar
Hitori Hitori is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2006
Posts: 360
try it to be shure
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:16 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0