如何在 .bash_profile macOS 中获取外部文件
How to source an external file in .bash_profile macOS
我试图将我的脚本从 linux 移动到 mac,文件夹 ~/Scripts 与所有其他脚本一起放在 home,
但是在 .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 ]] ; then
printf "ipmitool <Host IP> \n\n"
else
ssh con_1 ipmitool -I lanplus -U * -P * -H fru print
fi
航站楼
1232324fa:~ OiO$ ipmitool
-bash: ipmitool: command not found
1232324fa:~ OiO$ bash ~/Scripts/ipmitool
ipmitool <Host IP>
我需要在前面使用bash
才能调用ipmitool,在linux中我只需要输入ipmitool。
我试着按照这个 但是没有成功。
谁能帮助这个新手,谢谢。
您似乎不想采购它。您想要将 ~/Scripts
添加到您的路径,以便稍后您可以键入 ipmitool
而不是 ~/Scripts/ipmitool
来执行它。
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
PATH=~/Scripts:$PATH
alias test='echo test from bash_profile'
(确保 ~/Scripts/ipmitool
也是可执行的,通过 运行
chmod +x ~/Scripts/ipmitool
)
我试图将我的脚本从 linux 移动到 mac,文件夹 ~/Scripts 与所有其他脚本一起放在 home,
但是在 .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 ]] ; then
printf "ipmitool <Host IP> \n\n"
else
ssh con_1 ipmitool -I lanplus -U * -P * -H fru print
fi
航站楼
1232324fa:~ OiO$ ipmitool
-bash: ipmitool: command not found
1232324fa:~ OiO$ bash ~/Scripts/ipmitool
ipmitool <Host IP>
我需要在前面使用bash
才能调用ipmitool,在linux中我只需要输入ipmitool。
我试着按照这个
谁能帮助这个新手,谢谢。
您似乎不想采购它。您想要将 ~/Scripts
添加到您的路径,以便稍后您可以键入 ipmitool
而不是 ~/Scripts/ipmitool
来执行它。
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
PATH=~/Scripts:$PATH
alias test='echo test from bash_profile'
(确保 ~/Scripts/ipmitool
也是可执行的,通过 运行
chmod +x ~/Scripts/ipmitool
)