- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Something about shell scripting.
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
09-13-2001 08:37 PM
09-13-2001 08:37 PM
Something about shell scripting.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2001 08:51 PM
09-13-2001 08:51 PM
Re: Something about shell scripting.
The "script" should be a absolute path of your environment variable script and NOT a variable because it cannot pass through to a 'su -c' command.
Regards,
Patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2001 08:54 PM
09-13-2001 08:54 PM
Re: Something about shell scripting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2001 11:19 PM
09-13-2001 11:19 PM
Re: Something about shell scripting.
what you could do is writing your variables into a file before su-ing.
echo "export VAR='$VAR'" >/tmp/set_variables
echo "export VAR1='$VAR1'" >>/tmp/set_variables
and so on ...
chown $account /tmp/set_variables
Then in the script of $account add the line
. /tmp/set_variables
Hope this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2001 11:23 PM
09-13-2001 11:23 PM
Re: Something about shell scripting.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2001 11:36 PM
09-13-2001 11:36 PM
Re: Something about shell scripting.
I think it's the shell problem because I encounter it before. Sometime you call a ksh script but it internal call another sh script will cause you not to get any environment variable which specific in the sh script.
Regards,
Patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2001 01:00 AM
09-14-2001 01:00 AM
Re: Something about shell scripting.
See inside your .profile files, and other involved files such as $HOME/.chsrc, .kshrc and /etc/profile for that variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2001 01:34 AM
09-14-2001 01:34 AM
Re: Something about shell scripting.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2001 01:44 AM
09-14-2001 01:44 AM
Re: Something about shell scripting.
Create a file /tmp/jj
echo JJ="-"$JJ"-"
export JJ in the original shell
JJ="OK"
export JJ
and now
su - user -c "/tmp/jj"....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2001 12:31 PM
09-14-2001 12:31 PM
Re: Something about shell scripting.
since only a process can modify its own environment,
you could do something like:
su - USER -c "ENV=$HOME/.special-vars sh "
where "$HOME/.sprecial-vars" would be shell-script
(with permissions "r" and "x") containing all the
"export" statements and variable assignments you
need...
Since Korn-Shell and POSIX-Shell both do execute the
script referred to in "ENV" before showing the prompt,
that would do what yout want.
OR, you may have a line in your "$HOME/.profile" like
this:
if [ -r $HOME/.variables ]; then . $HOME/.variables; fi
Hence, if there is a script ".variables" it will be sourced
into your login shells (and "su -", too). Then you will just
have to create or modify that script...
Just my ?0.02,
Wodisch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2001 12:03 AM
09-17-2001 12:03 AM
Re: Something about shell scripting.
at least on Linux there are two slightly different ways to submit the su command:
su $account
or
su - $account
The difference is that with "-" (means login) there will be a completely new environment whereas without the old environment will be used. I tried that:
tboerner@N01049LUX:~/Download > export MY_TEST_VARIABLE="Some dummy value"
tboerner@N01049LUX:~/Download > echo $MY_TEST_VARIABLE
Some dummy value
tboerner@N01049LUX:~/Download > su - tb
Password:
tb@N01049LUX:~ > echo $MY_TEST_VARIABLE
tb@N01049LUX:~ > logout
tboerner@N01049LUX:~/Download > echo $MY_TEST_VARIABLE
Some dummy value
tboerner@N01049LUX:~/Download > su tb
Password:
tb@N01049LUX:/home/nokia/Download > echo $MY_TEST_VARIABLE
Some dummy value
tb@N01049LUX:/home/nokia/Download > exit
tboerner@N01049LUX:~/Download > echo $MY_TEST_VARIABLE
Some dummy value
Hope that helps a bit to explain your question.
Have a nice day
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2001 06:53 AM
09-17-2001 06:53 AM
Re: Something about shell scripting.
>>>
Kenny, apparently on the machines where things work, the environmental vars you need are being set globally at the start of each user shell (like from /etc/profile). Compare the /etc/profiles from a system where things work and from a system where things are broken, and you'll probably see what's happening.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2001 02:24 AM
09-18-2001 02:24 AM
Re: Something about shell scripting.
I agree with Thomas, there is a difference wether you are using the "-" or not.
This is clearly documented on the man page of su. Unfortunately su has been withdrawn from the XPG and POSIX standards. That could explain diverging implementations on different OS. There is no difference between HPUX10 and HPUX11 with respect to the su man page.
Klaus