Solved

how to run script shell with specific uid and gid ?

Posted on 2008-10-15
2
425 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Today companies are subjected to more-and-more data, and it won't stop any time soon.  But there are obvious opportunities for reducing data, particularly data duplicated among companies.
In our personal lives, we have well-designed consumer apps to delight us and make even the most complex transactions simple. Many enterprise applications, however, are a bit behind the times. For an enterprise app to be successful in today's tech wo…
This video shows how use content aware, what it’s used for, and when to use it over other tools.
This video demonstrates how to use each tool, their shortcuts, where and when to use them, and how to use the keyboard to improve workflow.

726 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