Solved

how to run script shell with specific uid and gid ?

Posted on 2008-10-15
2
423 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If your app took Google’s lash recently, here are the 5 most likely reasons.
This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
The viewer will learn common shortcuts with easy ways to remember them. The viewer will then learn where to find all of the keyboard shortcuts, how to create/change them, and how to speed up their workflow.
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…

792 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