2021年4月3日星期六

Using escape characters inside double quotes in ssh command in bash script

I want to run some commands each time when I log in to a remote system. Storing commands in .bashrc on remote is not an option.

What is the proper way to escape the escape chars inside of quotes in bash script for ssh? How can I write each command in new line?

My script

#!/bin/bash    remote_PS1=$'\[\033[01;32m\]\u@\[\033[03;80m\]\h\[\033[00m\]:\[\033[01;34m\]\!:\w\[\033[00m\]\$ '  ssh -t "$@" 'export SYSTEMD_PAGER="";' \              'export $remote_PS1;' \              'echo -e "set nocompatible" > /home/root/.vimrc;' \              'bash -l;'  

didn't work.

https://stackoverflow.com/questions/66938430/using-escape-characters-inside-double-quotes-in-ssh-command-in-bash-script April 04, 2021 at 02:05PM

没有评论:

发表评论