- There are two systems A and B
- On System B, there are two users : test1 and userX. Both are
- Its required to run a script from system A, which will access system B with credentials of userX and need to do
suwith a single commandline option
- This will be scripted which have to be run automatically without human intervention.
- The requirement is to access user test1's variables via this script. How to do that?
- Those variables not global. These variables are declared in
[test1@localhost ~]$ cat .bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin VAR=test1 export PATH VAR
- The command into the scripts are as follows.
# ssh userX@192.168.0.254 sudo su - test1 -c 'echo $VAR'
- Where System B is 192.168.0.254 and variable
VARhas to print the value in it.
- Red Hat Enterprise Linux 6
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.