• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 300
  • Last Modified:

script that switch users

(Solaris2.7)
I want to write a script that among other things switch users. (It runs under root)
How do I do that?
0
wabby26
Asked:
wabby26
  • 4
  • 3
  • 2
1 Solution
 
RobWMartinCommented:
Friendly advice,

More detail, more points (esp. if you want someone to write a script for you)

Meanwhile, have you looked at su?

man su

0
 
wabby26Author Commented:
This is not a script this is only one command and for that you want more points? This is an EASY question.
0
 
RobWMartinCommented:
Didn't mean to offend you.  I don't need more points.  I was literally giving you some *friendly* advice.  

If you want someone to take the time to figure out the details you left out of your question and then write a script, you'll need to cough up more points.  Friendly types, like me, abound, and may help you write the script for 50 pts, but not many are going to beg you for more detail.

You obviously didn't even take the time to man su.  You may be able to figure it out on your own and not spend any points!

Good luck,
Rob
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
tfewsterCommented:
Just put `/bin/su - username' in your script. The best use for this in a script is to do a particular task as that user, e.g. database backups that requires a specific user ID plus their environment.

e.g.
/bin/su - oracle -c /home/oracle/backupscript > /home/oracle/backuplog

- becomes user oracle & does a backup, saving any output to a file. Such a command could be put in a cron job
0
 
RobWMartinCommented:
You know the old saying:

Give a man a fish, he'll eat for the day; teach him to fish, he'll eat for life.

tfewster has learned to fish, i.e. man su

wabby26 just got a fish.  Sad :(

Well, that's why tfewster is the expert.  Good job, dude!

0
 
wabby26Author Commented:
Rob - I guess I gave enough details because this is what I needed.
10x anyway.
tfewster - 10x.
0
 
tfewsterCommented:
wabby - Thanks

Rob - I know what you mean, but I thought wabby might just want a quick practical example.
0
 
wabby26Author Commented:
Rob - This IS what I needed. I didn't ask to write me a program, I just asked for a one little command.
Do you really think I should spend time on looking for one command that many people already know? In that time I can do things that have more value.
0
 
RobWMartinCommented:
You're not gonna at least let me have the last word, are you? :)

If you'll will reread your question you most certainly DID NOT ask for "one little command".  And I quote:

"... write a script that among other things ..."

I answered it as a fifty point (yes, easy) question, by pointing you to the su command.

My point was that if you want a script, it'll cost you or you won't get many bites.  I thought I was giving some helpful advice from my own experience.  I undervalued a question, once, and didn't get any help.

Anyhow, common courtesy on EE says give credit to the first one who gives the answer (whether it's a comment or proposed answer).  I pointed you to su, and you ultimately accepted su as the answer.  

There.  My chest truly feels lighter.  

Though I tend to get hyper, I really am glad you got the answer you were looking for.

Hope there are no hard feelings.

Rob
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now