Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ensuring that a script runs as the proper user 1

Status
Not open for further replies.

ddrillich

Technical User
Jun 11, 2003
546
US
Good Day,

Occasionally, the SAs bring up our apps as root instead of the autonomy user. Yesterday it caused here a lot of grief. The apps are invoked by shell scripts. How can we guarantee that the script runs as autonomy, preferably within the script?

Regards,
Dan
 
In Korn shell...
Code:
#!/usr/bin/ksh

[[ $(whoami) != "autonomy" ]] && echo "You must be logged on as autonomy to run this script" && exit

# The rest of your script goes here...
If anyone besides "autonomy" runs the script, the script will just print the error message of why it's not starting, then exit. Just slight changes needed for other shells.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top