【问题标题】:How to set the PATH in .profile or .bash_profile in ubuntu如何在 .profile 或 .bash_profile 在 ubuntu 中设置 PATH
【发布时间】:2016-11-04 06:03:44
【问题描述】:

我有一个使用 jmeter 的脚本。现在,我不想在脚本中给出像sh /home/ubuntu/apache-jmeter-3.0/bin/jmeter.sh -n -t fileName.jmx 这样的路径,我只想在脚本中给出sh jmeter.sh -n -t fileName.jmx。所以,我想在ubuntu 中设置jmeter 的PATH。我不明白该怎么做。有人可以帮忙吗?

我的 jmeter 的路径是:/home/ubuntu/apache-jmeter-3.0

【问题讨论】:

    标签: linux bash shell ubuntu path


    【解决方案1】:

    将目录/home/ubuntu/apache-jmeter-3.0/bin 添加到您的路径:

    export PATH="$PATH":/home/ubuntu/apache-jmeter-3.0/bin
    

    那么就可以直接使用了:

    jmeter.sh -n -t fileName.jmx
    

    要使其永久化,请将新的 PATH 声明添加到您的 ~/.bashrc

    【讨论】:

    • @user6348718 你是用jmeter.sh -n -t fileName.jmx运行的吗,注意前面没有sh..
    • 是的,它奏效了。我没有注意到在命令开始时删除 sh 。如果我想为此/home/ubuntu/apache-jmeter-3.0/lib/ext 设置路径,我可以在~/.bashrc 中添加另一行export PATH="$PATH":/home/ubuntu/apache-jmeter-3.0/lib/ext
    • @user6348718 是的,您可以,但请注意,如果您有太多这样的路径,您应该考虑使用符号链接到一个目录,并且只将该目录放在PATH
    • 我在~/.bashrc 中添加了一个类似export PATH="$PATH":/home/ubuntu/apache-jmeter-3.0/lib/ext 的语句,并尝试运行命令java -jar CMDRunner.jar --tool Reporter --generate-png BytesThroughputOverTime.png --input-jtl log.jtl --plugin-type BytesThroughputOverTime --width 800 --height 600.. 它不起作用并抛出错误消息找不到CMDRunner.jar
    • @user6348718 那是因为CMDRunner.jar 是命令java 的参数。 PATH 搜索命令,而不是参数。
    猜你喜欢
    • 2020-08-18
    • 2013-02-13
    • 2014-08-29
    • 2016-10-04
    • 1970-01-01
    • 1970-01-01
    • 2018-04-24
    • 2014-08-29
    • 2013-07-27
    相关资源
    最近更新 更多