If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > shell script from other user with same host

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-17-04, 00:08
MANASH3250 MANASH3250 is offline
Registered User
 
Join Date: Jan 2004
Location: Singapore
Posts: 19
Question shell script from other user with same host

Hi ,

I want to run some script from other user and print the output .
As for example . I am in host pdcdev0001 and with user gen001
and running some script . from this script i want to go to some other
user like neg002 and run some script and print the output from the
original user gen001 .

Usually we are switching from one user to other by become .

Please help me out in this regard .
It's a PRODUCTION issue so very very urgent .

Manash
__________________
Manash Ranjan
Reply With Quote
  #2 (permalink)  
Old 02-17-04, 02:44
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
Code:
su - neg002 -c "script" > logfile
__________________
Jean-Pierre.
Reply With Quote
  #3 (permalink)  
Old 02-17-04, 04:39
MANASH3250 MANASH3250 is offline
Registered User
 
Join Date: Jan 2004
Location: Singapore
Posts: 19
Hi ,

gen001 is not a super user . I tried to run this the error is coming like

Password:
su: Sorry


Could you please write in detail .

Thanks
__________________
Manash Ranjan
Reply With Quote
  #4 (permalink)  
Old 02-17-04, 04:58
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
As you are not root you need the password of the account to which you want to su, or the account must not have password.
__________________
Jean-Pierre.
Reply With Quote
  #5 (permalink)  
Old 02-17-04, 10:05
MANASH3250 MANASH3250 is offline
Registered User
 
Join Date: Jan 2004
Location: Singapore
Posts: 19
Hi Aigles ,

The problem is that i shouldn't show the password in the script as it is very critical because i am in production server . Any other alternative
to hide password ?

Thanks
__________________
Manash Ranjan
Reply With Quote
  #6 (permalink)  
Old 02-18-04, 04:46
S_Scheible S_Scheible is offline
Registered User
 
Join Date: Feb 2004
Posts: 17
You could give gen001 sudo permission to run
Code:
su - neg002 -c "script" > logfile
As he can run this one command as root when typing
Code:
sudo su - neg002 -c "script" > logfile
he is not prompted for a password. There's a ton of examples on how to achieve it in /etc/sudoers and man sudo/man sudoers I think.

Last edited by S_Scheible; 02-18-04 at 05:03.
Reply With Quote
  #7 (permalink)  
Old 02-18-04, 07:23
MANASH3250 MANASH3250 is offline
Registered User
 
Join Date: Jan 2004
Location: Singapore
Posts: 19
Again it is asking for password . My problem is that i don't want to show password in my script . Please help me out . I am using SUN SOLARIS Unix .
__________________
Manash Ranjan
Reply With Quote
  #8 (permalink)  
Old 02-18-04, 07:33
S_Scheible S_Scheible is offline
Registered User
 
Join Date: Feb 2004
Posts: 17
Can you post your line in /etc/sudoers for the command?
Reply With Quote
  #9 (permalink)  
Old 02-18-04, 07:38
MANASH3250 MANASH3250 is offline
Registered User
 
Join Date: Jan 2004
Location: Singapore
Posts: 19
In /etc there is no file called sudoers so where should i post .
Please reply describing what to do and where to post
__________________
Manash Ranjan
Reply With Quote
  #10 (permalink)  
Old 02-18-04, 07:52
S_Scheible S_Scheible is offline
Registered User
 
Join Date: Feb 2004
Posts: 17
Hmm are you sure you have 'sudo' installed? I am not sure where the config file is located on Solaris, it is /etc/sudoers for many flavors of Linux.

Last edited by S_Scheible; 02-18-04 at 08:00.
Reply With Quote
  #11 (permalink)  
Old 02-18-04, 09:40
skd skd is offline
Registered User
 
Join Date: Sep 2003
Posts: 71
try creating a file ".netrc" in your home directory with permission 400.

format of .netrc file woule be
============================================
machine hostname_here login loginid_here password password_here
=============================================

add asmany as hostname entries in this file
field 1,3,5 are reserve word
field 2,4,6 are variables
Reply With Quote
  #12 (permalink)  
Old 02-25-04, 07:02
MANASH3250 MANASH3250 is offline
Registered User
 
Join Date: Jan 2004
Location: Singapore
Posts: 19
yes, i made .netrc in the home directory where the original script resides now how to run the shell script from another user where
i wants to run the script and take the output ????
__________________
Manash Ranjan
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On