linux - 如何在脚本中运行 .profile
问题描述
当我在脚本下面运行时,我必须先 SU 并在脚本中运行配置文件。配置文件正在向终端提供日志,参数在 profiel 中解析或不解析下一行。提前谢谢
if [ $owner = "user1" ]
then
su -c " . ~/.profile; cd $LOG_DOR; cat $job.log" - user1
else
echo "$owner not found"
fi
解决方案
要将文件读入当前 shell,请使用source
source ~/.profile
推荐阅读
- arrays - ruby 中的数独生成器
- python - 具有非平凡约束的多元优化?
- java - Artemis ActiveMQ + MDB 长时间工作:重新交付前等待多长时间
- javascript - 如何将重复的数字转换为对应的数字-字母对?
- sql - PL/SQL 遍历选择结果 - 将结果连接到可返回类型
- javascript - JS如何记录本地信息以备后用
- android - Android DataStore:从 Java 调用 Context.createDataStore
- javascript - 启用 TextArea 以使用 JQuery 进行编辑
- python - 使用 ctypes 调用 C 库时,Python 无法正确打印 long long integer
- c# - Logging .Net 5 后的调用方法