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
execute a .jil file OSD Shell Programming and Scripting 4 10-05-2007 01:20 AM
execute a .jil file OSD UNIX for Advanced & Expert Users 1 10-03-2007 06:11 AM
Sudo file not saved Asteroid UNIX for Advanced & Expert Users 0 07-30-2007 08:18 AM
how to configure the sudo file in solaris krishna176 SUN Solaris 2 03-25-2007 12:40 AM
Need to execute 2 scripts, wait, execute 2 more wait, till end of file halo98 Shell Programming and Scripting 1 08-01-2006 05:42 PM

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 06-13-2008
_prasad _prasad is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 4
Execute .sh file with sudo in it

Hi,
I logged into a UNIX system as user ABC.
I do not have root previleges and also do not have root password.

I am executing few commands as:
ABC****>sudo su - XYZ
XYZ****>rm file1.txt
XYZ****>exit
ABC****>

Now I want to execute all these commands from a .sh file ( or in any other way). I put all these commands in a test.sh and executed as

ABC****>./test.sh

the problem here is that , only first command is executed and control is gone to
XYZ****>

When I entered exit as
XYZ****>exit

the remaining commands in the test.sh started the execution as

ABC****>rm file1.txt
No Permission.
ABC****>exit

How should I execute the "rm file1.txt" as a XYZ user?
  #2 (permalink)  
Old 06-13-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,763
Why don't you invoke find to get the names of every file you are going to want to delete, park the name in a script, sudo to XYZ, run the script.

Or sudo to XYZ ,cd to the directory with a problem, then
Code:
chown -R ABC *
You will see lots of errors for files XYZ does not own. But now all of XYZ's files in the whole directory tree belong to ABC.
  #3 (permalink)  
Old 06-13-2008
_prasad _prasad is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 4
no luck

I did this, but got this error :
Permission denied
Closed Thread

Bookmarks

Tags
unix commands

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 12:01 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