Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ssh command with eval?

Status
Not open for further replies.

bgreen

Programmer
Feb 20, 2003
185
CA
Hi,


I am writting a dynamic script to go to several hosts and i have hit a road block. I want to check and see if a directory exists on another server. I ask for the environment and I ask for the path. The path would be a "env" variable (ie. $COMMON_TOP). I try to run the following code and it only work on "PROD" but I would like it to also check on other local hosts/env's using ssh. Any suggestion? Here is a snippet of code.

print -n "\n What environment file copied from (PROD): "
read FRENV (ie. PROD)

FRLOWER=`echo $FRENV | tr '[:upper:]' '[:lower:]'`
FRUPPER=`echo $FRENV | tr '[:lower:]' '[:upper:]'`

case ${FRLOWER} in
"conv"|"train"|"patch"|"devl"|"intf")
FRHOST=p690lp4
;;
"prod")
FRHOST=p690lp1
;;
esac

print -n "\n Path to get file: " (ie. $COMMON_TOP)[\b]
read FRPATH
eval FRPATH="${FRPATH}" (ssh statement here????)
echo ${FRPATH} (OUTOUT -> /u2/oracle/prodcomn)
 
If you ssh somehost command it won't run the .profile (or .bash_profile, or .login depending on which shell you use), so you will have to do that manually if that is where the environment variable is defined, e.g.

[tt]ssh hosname ". ./.profile ; echo ${FRPATH}"[/tt]

Annihilannic.
 
Thanks for the suggestion. Unfortunatly we have 4 environments on the box I am trying to get the path. We run a script at initial login to set environments.
 
So run that script instead of .profile using the method I suggested?

How do you usually select which of the 4 environments on to use on that that box... does it prompt you when you log in or something?

Annihilannic.
 
It asks for a number selection. This is in a menu form.

1. CONV Apps env
2. CONV 9i DB env

etc....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top