bash - 如何在 .bash_profile macOS 中获取外部文件
问题描述
我试图将我的脚本从 linux 移动到 mac,文件夹 ~/Scripts 与所有其他脚本一起放在家里,
但使用 source in.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。
我试图按照这个如何在 OSX 的 .bash_profile 中获取外部文件?但没有用。
有人可以帮助这个新手,谢谢。
解决方案
看起来您不想获取它。您想要添加~/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
)
推荐阅读
- apache-spark - Spark pivot groupby 性能非常慢
- php - 用自定义字段值替换 Woocommerce 产品库存状态
- amazon-web-services - 跟踪“上次使用”之外的 IAM 访问密钥使用情况
- powershell - Powershell:如何让 powershell 在您使用已知名称搜索时为您提供选择正确用户的选项
- javascript - Shopify Admin API 无法在 Google 托管服务器上运行,但可以在 localhost 上运行
- iis - HTTPS 重定向重写规则在 IIS 中不起作用
- laravel - Laravel 5 - 在验证时清理某些输入
- javascript - 来自 React 组件的异步/等待调用操作
- r - 将 R 中的数据框与行名中的重复值合并
- linux - 在bash中迭代数组时获取变量名