bash - how I call the source ~./.bash_profile script from another shell script?
问题描述
I what to call source.sh script in another script main.sh script source.sh has following
#!/bin/sh
~/.bash_profile
#main.sh has following
tar -xzvf /home/admin/perf/jdk-8u201-linux-x64.tar.gz >> /home/admin/perf/output.txt &&
sleep 1
echo "Export Path for Environmental Variable"
sudo echo "export PATH=/home/admin/perf/jdk1.8.0_201/jre/bin/:/home/admin/perf/jdk1.8.0_201/bin/:$PATH" >> /home/admin/.bash_profile
sudo echo "export JAVA_HOME=:/home/admin/perf/jdk1.8.0_201" >> /home/admin/.bash_profile
sleep 1
echo "Persisting JDK PATH to .bash_profile"
source /home/admin/perf/./source.sh
when I execute ./main.sh
#Result is ./source.sh script is not setting the export path in the same shell.
解决方案
#!/usr/bin/bash
用于重生 shell,意思是 bash,在大多数系统上,这是 bash 脚本的第一行,您的行#!/bin/sh
可能不正确。但我可能错了。
要调用 bash_profile,您可以输入source ~/.bash_profile
,但我会查看第一行,即解释器。
推荐阅读
- gradle - '。' 运行 ./gradlew 时不被识别为内部或外部命令
- insert - Greenplum 日期/时间字段超出范围:“2020 年 10 月 10 日”
- wpf - 如何在表单中的用户控件上添加工具箱中的控件
- python - 如何在 python 的高维数组中应用多处理?(问题从未解释)
- matlab - 如何在 Matlab 中对以下代码进行矢量化?
- elasticsearch - 用于查询和排序的多字段与字段数据
- c# - Unity Android App Crash with physx::Gu::PersistentContactManifold::reduceBatchContacts
- docusignapi - 错误:错误:0909006C:PEM 例程:get_name:没有起始行 - 节点
- git - git push ssh on ubuntu '请确保您拥有正确的访问权限'
- c++ - 为什么 boost::condition_variable 可以使用 pthread_cond_signal 只唤醒一个线程