- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to successfully su another user and run hi...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2002 11:20 AM
11-08-2002 11:20 AM
I want to write a simple script with following purpose:
I want User A su User B
User A will run a script in User B's directory.
$ ll test
-rwxrwxrwx 1 ssprod sybase 86 Nov 8 14:07 test
This is what I wrote in a file "test"
"su - UserB -c /UserB/octacom/sqllist.sh
When I run it, nother happens. But If I run manually by su UserB and run it in UserB's diectory, it will work.
Can anyone give me suggestions?
Thanks
Yalin
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2002 11:19 AM
11-08-2002 11:19 AM
Re: How to successfully su another user and run his scripts
Try this instead:
su - UserB -c "/UserB/octacom/sqllist.sh
Hope this helps
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2002 11:20 AM
11-08-2002 11:20 AM
Re: How to successfully su another user and run his scripts
The quotes need to surround the -c command string - not the entire command.
Rgds,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2002 11:26 AM
11-08-2002 11:26 AM
Re: How to successfully su another user and run his scripts
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2002 11:41 AM
11-08-2002 11:41 AM
Re: How to successfully su another user and run his scripts
su - UserB -c "/UserB/octacom/sqqlist.sh"
none of them works
Note: I changed the permission of the scripts
to 777.
the "
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2002 11:45 AM
11-08-2002 11:45 AM
Re: How to successfully su another user and run his scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2002 11:46 AM
11-08-2002 11:46 AM
Re: How to successfully su another user and run his scripts
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2002 11:47 AM
11-08-2002 11:47 AM
Re: How to successfully su another user and run his scripts
HTH
Marty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2002 11:54 AM
11-08-2002 11:54 AM
Re: How to successfully su another user and run his scripts
Are you calling this pwd file by it's absolute path or are you just calling the file name?
You either have to do this:
su - UserB -c "/UserB/octacom/sqllist.sh
or
PWD=/full/path/to/pwd
.
.
.
su - UserB -c "/UserB/octacom/sqllist.sh <$PWD"
Hope this helps
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2002 11:55 AM
11-08-2002 11:55 AM
Re: How to successfully su another user and run his scripts
Your other option would be for UserB to setup a .rhosts file that gives UserA equivalency rights to UserB.
Rgds,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2002 11:57 AM
11-08-2002 11:57 AM
SolutionThere are two ways to make this work:
1) surround any of the commands which deal with the terminal with
if [ -t 0 ]
then
tset ....
stty ....
tabs ...
fi
-t 0 is true if stdin (0) is a terminal device.
2) better
have a file that both .profile and your script sources (e.g) . /usr/local/bin/myenv.sh
myenv.sh would then set and export any needed vars.
There should be no exits or returns in this file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2002 12:00 PM
11-08-2002 12:00 PM
Re: How to successfully su another user and run his scripts
http://gatekeep.cs.utah.edu/hppd/hpux/Sysadmin/sudo-1.6.6/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2002 09:21 AM
11-11-2002 09:21 AM
Re: How to successfully su another user and run his scripts
/bin/nohup /bin/su - phlmgrd -c '/opt/cognos/license1/lmgrd /opt/cognos/license1/lmgrd.log2> /opt/cognos/license1/lmgrd.err & '
Regards
Gerhard