0

我的主目录中有一个脚本。该脚本仅提供一条消息作为输出。我正在尝试让我的:执行脚本,以便我可以看到此消息。.profile

我正在尝试将我的个人资料用作日志。所以我可以找到错误。

我的问题是,既然脚本调用了一个基本echo请求,我是否必须将我的消息传递给一个变量,以便它可以传递给那个.profile

当我实施ISPOD = Home/isProd export ISPROD将其提供给我.profile的消息时,该消息不存在。我该如何解决这个问题。

4

1 回答 1

1

There are several things to consider here. When you do

ISPROD=$HOME/isProd

the actual content of your variable is the isProd path, and not its output. If you want to execute the command and catch the output then try $(command) or `command`.

ISPROD=$($HOME/isProd)

or

ISPROD=`$HOME/isProd`

at this point ISPROD will contain the output of the script. But you still need to show the content, hence you need to add

echo "$ISPROD"

But the same behaviour can be achieved just by executing the command without capturing the output and then echoing it. Try with putting directly

$HOME/isProd

in the .profile and source it. Also, make sure that .profile is the actual file that the shell sources at login time (bash for example uses .bash_profile).

于 2013-03-09T00:09:10.067 回答