Solved

how to run script shell with specific uid and gid ?

Posted on 2008-10-15
2
416 Views
Last Modified: 2013-12-12
hello,
I have make one script shell, and i want this script shell are start with specific user.
add "su deploy" in my script is not good because avec this line is executed the script stop imediatly
and other solution :
#!/bin/sh
exec 2>&1
exec envuidgid deploy /home/deploy/deploy/run

generate error : "envuidgid: fatal: unable to run /home/deploy/deploy/run: exec format error"
I think is not possible to exec script shell with this solution, this solution work only with programe.

have you one solution ?

and it's possible after have exec this "ssh deploy@www1:~/script_distant"
close this ssh conection for exec next line of my script shell ??

thank you
thierry
0
Comment
Question by:thierry91
2 Comments
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 200 total points
ID: 22725287
sudo is the best option for this (assuming you have it installed on your system)

You would create a sudo entry in sudoers (with the visudo command) like:

User_Alias     DEPLOYUSERS = user1,user2,user3
DEPLOYUSERS = ALL = (deploy) NOPASSWD:  /home/deploy/deploy/run

Then your calling script would simply be

sudo -u deploy /home/deploy/deploy/run
0
 
LVL 40

Accepted Solution

by:
omarfarid earned 300 total points
ID: 22727780
When you run the script, are you calling it from root account? If yes then

su user1 -c "/path/to/script args"

this will let you run the script as user user1 ( with group ids of which this user is a member)
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Skype is a P2P (Peer to Peer) instant messaging and VOIP (Voice over IP) service – as well as a whole lot more.
Using Adobe Premiere Pro, the viewer will learn how to set up a sequence with proper settings, importing pictures, rendering, and exporting the finished product.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now