I need to Obtain my remote Linux Server eth1 IP address using bash script through the ssh and i have following command: /sbin/ifconfig eth1 | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'
but when i run :
spawn ssh -t $user@$remote_host "/sbin/ifconfig eth1 | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $2}' ; echo $ip "
it says can't read "1": no such variable
while executing
"spawn ssh -t $user@$remote_host "ip=/sbin/ifconfig eth1 | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'
; echo $ip ""
(file "./ssh2.sh" line 11)
So could please help me with this issue. Thanks