- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Passing variables in su commands
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
12-25-2008 11:21 PM
12-25-2008 11:21 PM
I wanted to do something simple. I want to use "su - username" command to be able to run a script using that user's environment variables.
It is something like this:
su - username -c '/path/to/script $var1'
The var1 is an input from somewhere else in the script.
I keep getting parameter not set (which is $var1). So it seemed that su couldn't accept parameterized arguments?
Any input would be much appreciated.
Thanks,
=adley=
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2008 11:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2008 11:31 PM
12-25-2008 11:31 PM
Re: Passing variables in su commands
I've tried using single and double apostrophe for var1 as well (and a few escape attempts). I know that single usually make the $ to be literal (I used double apos everywhere else). Just on this one line that I'm stuck.
=adley=
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2008 11:47 PM
12-25-2008 11:47 PM
Re: Passing variables in su commands
(These are better known as single and double quotes.)
What Steven was saying is that you should use:
su - username -c "/path/to/script $var1"
You can test with:
su - username -c "echo $var1"
>I know that single usually make the $ to be literal
Right, you don't want that, unless you want to query the environment variables in the new user's shell.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2008 12:34 AM
12-26-2008 12:34 AM
Re: Passing variables in su commands
Thanks for the posts. I managed to get it to work.
Steven, sorry about missing your point earlier as well :)
Dennis, yes, it should've been "quotes" instead of the other :)
Thanks,
=adley=