ssh & if togher in shell script

hi guys!!!

how can i check remote location(if is existing or not)...this script runs on local machine and only allow ssh or scp ...not telnet.
$PVT_TGTLOC= remote machine location


  # PREPARE TARGET LOCATION IF NEEDED
  # --------------------------------------------------------------------------------------------------|
  if ! [[ -d "$PVT_TGTLOC" ]]
   then
    mkdir -p "$PVT_TGTLOC"
  fi

  # VERIFY TARGET LOCATION
  # --------------------------------------------------------------------------------------------------|
  # CHECK DIRECTORY STATUS AND THROW EXCEPTION IF APPLICABLE
  if ! [[ -d "$PVT_TGTLOC" ]]
   then
    # * Throw exception
 
    # * Cleanup and return
    unset_private -q ; set -- ; return 255
  fi
parlepointAsked:
Who is Participating?
 
omarfaridCommented:
Hi,

you may do something like this:

PVT_TGTLOC=/remote/path
export PVT_TGTLOC

eval ssh remoteuser@remoteserver "PVT_TGTLOC=$PVT_TGTLOC ; export PVT_TGTLOC ; myremotescript"

0
 
ahoffmannCommented:
what do you mean by  "check remote location"?
0
 
parlepointAuthor Commented:
sorry i mean that remote application folder structure.

i have /home/a/b/c/d/e/f/g to be create in remote machine...which has only /home/a/b.
how can i do with script..
script which i posted that kind of similiar but i have to create with ssh.

give me solution.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
ahoffmannCommented:
mkdir -p /home/a/b/c/d/e/f/g
0
 
parlepointAuthor Commented:
thanks...it works..for folder structure..but now after ssh how can pass TGTLOC variable to script...which is running in remote location.
0
 
ahoffmannCommented:
ssh user@remote  'PVT_TGTLOC=whatever /path/to/script'
0
 
parlepointAuthor Commented:
First  PVT_tgtloc verify destination and if is not there then create folder structure..
how i will give after ssh ???
0
 
ahoffmannCommented:
you better write a script and execute it remote
0
 
parlepointAuthor Commented:
That waz great help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.