d*y 发帖数: 7 | 1 有一条命令(专用的utility),我可以在shell中执行。但如果我在script中去调用它
,系统汇报“command not found”
我用which 和 whereis 都找不到这个命令的路径。
我怎么能在script中用它呢?
谢谢! |
l****h 发帖数: 272 | 2 full path name?
【在 d*y 的大作中提到】 : 有一条命令(专用的utility),我可以在shell中执行。但如果我在script中去调用它 : ,系统汇报“command not found” : 我用which 和 whereis 都找不到这个命令的路径。 : 我怎么能在script中用它呢? : 谢谢!
|
H****n 发帖数: 175 | 3 source your shell rc file : .bashrc
or
find the path line in your .bashrc
then copy it to your script
【在 d*y 的大作中提到】 : 有一条命令(专用的utility),我可以在shell中执行。但如果我在script中去调用它 : ,系统汇报“command not found” : 我用which 和 whereis 都找不到这个命令的路径。 : 我怎么能在script中用它呢? : 谢谢!
|
v*****r 发帖数: 1119 | 4 No environment variables should be put in .bashrc file.
LZ could use full path of the command in script, or export PATH in .bash_
profile or .profile
【在 H****n 的大作中提到】 : source your shell rc file : .bashrc : or : find the path line in your .bashrc : then copy it to your script
|
d*y 发帖数: 7 | 5 Don't know. It is what I tried to get using which and whereis.
【在 l****h 的大作中提到】 : full path name?
|
d*y 发帖数: 7 | 6 source ~/.bashrc can solve this problem. Thanks!
ut why ...
I have found that that command is a function defined in one system .bashrc
file
【在 H****n 的大作中提到】 : source your shell rc file : .bashrc : or : find the path line in your .bashrc : then copy it to your script
|
v*****r 发帖数: 1119 | 7 What is the first line in your script?
The shell used to run the script is not bash, otherwise you don't need to
source .bashrc file
【在 d*y 的大作中提到】 : source ~/.bashrc can solve this problem. Thanks! : ut why ... : I have found that that command is a function defined in one system .bashrc : file
|
d*y 发帖数: 7 | 8 It was
#!/bin/sh
and I tried to change it to
#!/bin/bash
But it still need to source ~/.bashrc to find that command.
【在 v*****r 的大作中提到】 : What is the first line in your script? : The shell used to run the script is not bash, otherwise you don't need to : source .bashrc file
|