- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- env variable different when logon to system vs ssh...
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
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
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
01-05-2011 01:38 PM
01-05-2011 01:38 PM
I have noticed my env gets setup different depending on how I log into the system. Here is an example to issistrate what I am trying to figureout.
1. >ssh ojrdres1 env (then give passwd)
• Env listing is very short .. it is not reading my .profile
2. >ssh ojrdres1 (then give passwd)
3. >env
• Env listing is what I expect .. it is reading my .profile.
Do you know how I can perform 1 and get it to read my .profile, and the system .profile?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2011 02:50 PM
01-05-2011 02:50 PM
Re: env variable different when logon to system vs ssh system "env"
But when you are in remote command execution mode, i.e., your option (1), you will not get your ENVIRONMENT variable like you get during an interactive session. You need to call almost every each command by its absolute path unfortunately.
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2011 02:58 PM
01-05-2011 02:58 PM
Re: env variable different when logon to system vs ssh system "env"
approximately nothing about _your_ "the
system", but on mine, "man ssh" says:
[...]
If command is specified, it is executed on the remote host instead of
a login shell.
[...]
> Do you know how I can perform 1 and get it
> to read my .profile, and the system
> .profile?
I wouldn't bet on how many things won't work
as expected, but you could try something
like:
echo env | ssh ojrdres1
That is, no "command" in the ssh command, so
it will read from stdin. For example:
dyi # ssh dyi 'echo $EDITOR'
dyi #
dyi # echo 'echo $EDITOR' | ssh dyi 2> /dev/null
Last successful login: Wed Jan 5 16:51:22 CST 2011 dyi.antinode.info
Last authentication failure: Thu Oct 14 12:59:57 CDT 2010 dyi.antinode.info
You have mail.
Value of TERM has been set to "".
WARNING: YOU ARE SUPERUSER !!
vi
dyi #
Fishing the desired result ("vi") out of the
log-in noise is only one of the problems with
a method like this.
As usual, some basic information about the
system(s) involved might be helpful:
uname -a
ssh -V
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2011 07:05 AM
01-06-2011 07:05 AM
Re: env variable different when logon to system vs ssh system "env"
SSH From
=====================
[root@ojrdlesapp21 ~]# uname -a
Linux ojrdlesapp21 2.6.18-194.11.1.el5 #1 SMP Tue Jul 27 05:45:06 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
[root@ojrdlesapp21 ~]# ssh -V
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
[root@ojrdlesapp21 ~]#
SSH TO
=========
ojrdhes3::ESDEV:/home/karl030> uname -a
HP-UX ojrdhes3 B.11.11 U 9000/800 522788742 unlimited-user license
ojrdhes3::ESDEV:/home/karl030> ssh -V
OpenSSH_3.9, OpenSSL 0.9.7d 17 Mar 2004
HP-UX Secure Shell-A.03.91.002, HP-UX Secure Shell version
ojrdhes3::ESDEV:/home/karl030>
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2011 07:18 AM
01-06-2011 07:18 AM
SolutionThe whole point of the remote command execution is to have a limited shell so you can run commands very quickly. If you need a specific environment for a specific command, you can set up a wrapper script:
#!/bin/ksh
. ./.profile
${my_command_of_choice}
#eof
for instance, then call that via :
ssh ${host} ~/bin/my_cmd
lastly, if you really want an environment for your commands, you can update the ~/.ssh/environment file - referenced in the ssh man page:
Additionally, ssh reads ~/.ssh/environment, and adds lines of the format "VARNAME=value" to the environment if the file exists and users are allowed to change their environment. For more information, see the PermitUserEnvironment option in sshd_config(5).
HTH;
Doug
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html