The cd command using variable to mapped NFS volume within ssh in linux script is not working
Posted
by
Bhavya Maheshwari
on Super User
See other posts from Super User
or by Bhavya Maheshwari
Published on 2013-02-04T10:18:44Z
Indexed on
2014/06/09
21:29 UTC
Read the original article
Hit count: 265
I have to do the following from within a bash script. The /VMNFS/ folder is present on linux box, from where script is run, and is mapped to the machine into which i am ssh'ing, as an NFS at /vmfs/volumes/VMNFS/. The second cd command doesn't work, neither with symbolic path name nor physical pathname. Why? and How to rectify this?
#!/bin/bash
ssh -2 [email protected] /bin/sh <<\EOF
vmfile_path=`grep / vmvar_file`
datastore_path=/vmfs/volumes/VMNFS/
cd $datastore_path && echo "The present working directory is" `pwd -P`
esxi_vmfile_path_sub=`pwd -P` && echo "variable value is" $esxi_vmfile_path_sub
esxi_vmfile_path=`echo $vmfile_path | sed "s:/VMNFS:$esxi_vmfile_path_sub:"`
cd "$esxi_vmfile_path"
EOF
***Output***:
The current working directory is /vmfs/volumes/65335ec4-46d12e41
variable value is /vmfs/volumes/65335ec4-46d12e41
can't cd to /vmfs/volumes/65335ec4-46d12e41/TPAE7.5/
© Super User or respective owner