• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 405
  • Last Modified:

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
0
parlepoint
Asked:
parlepoint
  • 4
  • 4
1 Solution
 
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
 
ahoffmannCommented:
mkdir -p /home/a/b/c/d/e/f/g
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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
 
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
 
parlepointAuthor Commented:
That waz great help
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now