対話型ログインまたは非対話型ログイン時に、ファイル構造に関係なく、常にユーザーのプロファイルと bash 構成ファイルを取得する方法を考え出したいと思います。また、マシンにインストールされている Linux の種類が関係ないのも良いでしょう。
たとえば、すべての人が ~/.bashrc ファイルまたは ~/.bash_profile ファイルを持っているわけではありませんが、持っている場合は、それらをソースとして読み込む必要があります。
私の最初の考えは次のようになります (これは ssh 後にプログラムで実行されます)。
[ -r /etc/profile ] && . /etc/profile;[ -r ~/.bash_profile ] && . ~/.bash_profile;[ -r ~/.profile ] && . ~/.profile;[ -r ~/.bashrc ] && . ~/.bashrc; OTHER COMMANDS...
しかし、これは私が計画したとおりには機能していません。.bashrc ファイルの関数がロードされていないようです。
ご協力いただければ幸いです。ありがとうございます。
編集: 完全なSSHコマンドの追加
ssh -p 22 dev@123 '[ -r /etc/profile ] && source /etc/profile;[ -r ~/.bash_profile ] && source ~/.bash_profile;[ -r ~/.profile ] && source ~/.profile;[ -r ~/.bashrc ] && source ~/.bashrc;cd ~/apps/my-project/;npm install;bower install;grunt production;~/start-apps.sh;' In my case, the command 'grunt' isn't being found because it's initiated in the .bashrc file.