【发布时间】:2020-10-23 00:19:00
【问题描述】:
我试图将我的脚本从 linux 移动到 mac,文件夹 ~/Scripts 与所有其他脚本一起放在家里,
但在.bash_profile 中使用源代码不会调用我的脚本。
.bash_profile 的内容
f [ -f ~/.bashrc ]; then
. ~/.bashrc
. ~/Scripts/ipmitool
fi
alias test='echo test from bash_profile'
/Scripts/ipmitool 的内容
#!/bin/bash
if [[ -z $1 ]] ; then
printf "ipmitool <Host IP> \n\n"
else
ssh con_1 ipmitool -I lanplus -U * -P * -H $1 fru print
fi
终端
1232324fa:~ OiO$ ipmitool
-bash: ipmitool: command not found
1232324fa:~ OiO$ bash ~/Scripts/ipmitool
ipmitool <Host IP>
我需要在前面使用bash才能调用ipmitool,在linux中我只需要输入ipmitool。
我尝试关注此How to source an external file in .bash_profile in OSX?,但没有成功。
有人可以帮助这个新手吗,谢谢。
【问题讨论】:
-
我猜你的 .bash_profile 中唯一的
f应该是if。做一个set -x; . ~/.bash_profle来调试它。您是如何验证您的.bash_profile的来源?