bash - Passing shell variables to ssh -
i read other postings on passing variables in remote ssh, solutions don't seem work me.
here situation: i'm populating values of variables throughout shell script (on local machine), used on another system via ssh. understand why isn't working, i'd find way use values in local shell on system via ssh.
build_server="my_server" another_server="my_server2" ssh $username@$build_server << 'endssh' echo "$build_server" echo "$another_server" endssh
when run code, these variables null. there way pass through values ssh?
i figured out. on line doing following:
ssh $username@$build_server << 'endssh'
i removed single quotes , interprets allow of local variables. if want use variable on remote server escape them "\"
ssh $username@$build_server << endssh echo $build_server # echos local server variable local_server="local_server" echo \$local_server # echos remote server variable endssh
Comments
Post a Comment