我无法让这个命令工作:
user@server:~: ssh otherserver bash -ic 'source .profile; some-aliased-command'
我尝试过的变化
user@server:~: ssh -t otherserver bash -ic 'source .profile; some-aliased-command'
user@server:~: ssh -t otherserver "bash -ic 'source .profile; some-aliased-command'"
user@server:~: ssh -t otherserver "bash -ic source .profile; some-aliased-command"
user@server:~: ssh otherserver bash -ic 'source .profile; some-aliased-command'
user@server:~: ssh otherserver "bash -ic 'source .profile; some-aliased-command'"
user@server:~: ssh otherserver "bash -ic source .profile; some-aliased-command"
我通常会收到这些错误的变体:
bash: cannot set terminal process group (-1): Invalid argument
bash: no job control in this shell
stdin: is not a tty
bash: some-aliased-command: command not found
但像这样,它确实有效:
user@server:~: ssh otherserver bash -i << EOF
source .profile
some-aliased-command
EOF
事实上,当我运行这个时:
ssh -t otherserver 'bash -ic "source ~/.profile; alias"'
它列出了所有别名,包括some-aliased-command
我想要运行的别名。
我尝试了各种单引号、双引号、转义引号的变体,但我被困住了,它只能与heredoc版本一起使用。
如果没有heredoc(作为单行代码),我如何使其工作?
答案1
与之前的答案相同,但添加了+m
作业控制问题修复:
ssh otherserver "bash -ic +m 'source .profile; some-aliased-command'"