I want to set an alias for the command:
expect -c 'spawn ssh usr@ip -p 57022 ; expect password ; send "pass\n" ; interact'
but quotes from alias alias_name=""
and from command doesn't like each other.
I tried combinations with '
, "
and `, but all of these failed.
How can I do that?
In American English, use double quotation marks for quotations and single quotation marks for quotations within quotations. In British English, use single quotation marks for quotations and double quotation marks for quotations within quotations.
To cause the C compiler to interpret the double quotation mark as a character, precede the double quotation mark with the C escape character, the backslash (\). The following example illustrates the correct syntax for the query in Table 1: EXEC SQL select col1 from tab1 where col1 = '\"';
In C and C++ the single quote is used to identify the single character, and double quotes are used for string literals. A string literal “x” is a string, it is containing character 'x' and a null terminator '\0'. So “x” is two-character array in this case. In C++ the size of the character literal is char.
A simple solution is to create a function, instead of an alias:
function function_name() {
expect -c 'spawn ssh usr@ip -p 57022 ; \
expect password ; send "pass\n" ; interact'
}
So you can call function_name
, and it will work just as fine as with an alias.
If you still want to use an alias, just escape the inner "
's:
alias alias_name="expect -c 'spawn ssh usr@ip -p 57022 ; expect password ; send \"pass\n\" ; interact'"
and it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With