The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
How do i change to super user then revert back to ordinary user ,using shell script? wrapster Shell Programming and Scripting 3 06-04-2008 08:11 AM
New User Looking for help with a shell script. WhitesinHolland Shell Programming and Scripting 7 02-13-2008 11:13 AM
su to another user in shell script akdwivedi Shell Programming and Scripting 1 08-15-2007 02:14 AM
Run shell script as different user mskarica UNIX for Advanced & Expert Users 8 04-30-2005 06:59 PM
User Shell script HOlli UNIX for Dummies Questions & Answers 2 01-08-2002 04:31 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 10-09-2007
pok.fung pok.fung is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 7
Smile allow another user to run my shell script in csh

I have a master shell script in csh to do some tasks where some output files will be created under a sub-directory. That shell script will also rsh to another host machine to run other shell scripts.

Since I want to allow a common user 'A' to execute my shell scripts in order to get the output files, my shell scripts will make a copy of the output files into a sub-directory under user 'A' home directory (user 'A' has set the folder permission to allow me to do so).

I set the file permission of my master shell script to be "-wrx-rx-rx" to allow user 'A' to run my master shell script so as to get the output files. However, when user 'A" executes my master shell script, some interactive prompt for confirmation appear, e.g. removing files or overwriting files, during the execution time. (no any interactive prompt if I run the shell script with my username)

I checked that user 'A' has set the alias rm as 'rm -i' and cp as 'cp -i'.

My questions:-
1) When user A executes my shell script, is the script executed under my own user environment or user A environment?
2) How can I allow user 'A' to only execute my shell script without privilege to read (hence not able to copy out)?
3) Any other better means to achieve my purposes?

Anyone can help. Thanks.
  #2 (permalink)  
Old 10-09-2007
_Spare_Ribs_'s Avatar
_Spare_Ribs_ _Spare_Ribs_ is offline
Registered User
  
 

Join Date: Dec 2006
Location: /dev/null
Posts: 72
1) it will be run under your environment use the "su -" with the username of the user whose environment you want to take on.

2) no, you need read privileges to be able to execute a file

3) well there are many ways to skin a cat depending on what you want to do. You say that the user is getting prompted it they want to remove files, well yes that's what the -i flag does. You can override this with -f (rm -f)to force the deletion of any file. This, of course, has its perils hence why the default on most distros these days is rm -i
  #3 (permalink)  
Old 10-09-2007
pok.fung pok.fung is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 7
Smile

Quote:
Originally Posted by _Spare_Ribs_ View Post
1) it will be run under your environment use the "su -" with the username of the user whose environment you want to take on.

2) no, you need read privileges to be able to execute a file

3) well there are many ways to skin a cat depending on what you want to do. You say that the user is getting prompted it they want to remove files, well yes that's what the -i flag does. You can override this with -f (rm -f)to force the deletion of any file. This, of course, has its perils hence why the default on most distros these days is rm -i
For 1), does it need password for "su -" to switch to my account

Foe 3), I already use "rm -f" for file deletion in all my shell scripts. From manual page, it seems that "rm -i" override "rm -f" indeed. If this is true, I may unalias the rm first before "calling" my shell script. Any ideas?
  #4 (permalink)  
Old 10-09-2007
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
no need to 'unalias' - just do "\rm -f" - this will skip the 'aliasing'
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 05:29 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