Output variable does not store value of "pbrun tsm_support.ksh -c $i" command while running this script though root.
通过root运行此脚本时,输出变量不存储“pbrun tsm_support.ksh -c $ i”命令的值。
#!/bin/bash
set -x
for i in `cat /home/unixlist.txt`
do
output=$(pbrun tsm_support.ksh -c $i)
echo $output >> /home/file.txt
if echo "$output" | grep -i "OPTION01" ;
then
echo successfull-- $i===$output
When I run this script from local user id it runs perfectly file and prints the output,
当我从本地用户id运行此脚本时,它运行完美的文件并打印输出,
Error-- DBSSS0006=== Starting checkfix script.....DBSSS0006:B:SunOS:1:1:2:0:Z
Error-- DBSSS0005=== Starting checkfix script.....DBSSS0005:B:SunOS:1:1:2:0:Z
but when I run this script from root it does not take the value of output variable. It does not take value of $output.
但是当我从root运行这个脚本时,它不会取输出变量的值。它没有取得$输出的价值。
Error-- DBSSS0006===
Error-- DBSSS0005===
I do not have root permissions, I can just edit crontab file and put my entry over there.
我没有root权限,我只能编辑crontab文件并将我的条目放在那里。
2 个解决方案
#1
1
The problem is the environment variables set in crontab versus the ones set on your command line. They are not the same.
问题是crontab中设置的环境变量与命令行中设置的环境变量。他们不一样。
To see what you have to change: Put this in you crontab:
要查看您需要更改的内容:将此内容放入crontab中:
* * * * * set > /tmp/crontab.txt
Save it, wait for 2 -3 minuite for it to run, then remove the crontab change.
保存它,等待2 -3 minuite运行,然后删除crontab更改。
Next:
set > /tmp/myenv.txt
diff /tmp/myenv.txt /tmp/crontab.txt
will show you the differences. Make some changes to your crontab script so it has (probably) the PATH variable and LD_LIBRARY_PATH variable changes you need. You do not have to change every environment variable.
会告诉你差异。对您的crontab脚本进行一些更改,使其(可能)具有您需要的PATH变量和LD_LIBRARY_PATH变量。您不必更改每个环境变量。
#2
0
Your problem is assuming powerbroker has the same environment variables when accessed in the batch mode as it is from the interactive terminal mode.
您的问题是假设powerbroker在批处理模式下访问时具有相同的环境变量,因为它来自交互式终端模式。
Even though it is impossible to say what deficiency exists there without seeing the actual tsm_support.ksh script contents, I can bet, there are assumptions made as in LD_LIBRARY_PATH will be the same everywhere and every time.
即使在没有看到实际的tsm_support.ksh脚本内容的情况下也不可能说出存在什么缺陷,我敢打赌,在LD_LIBRARY_PATH中做出的假设在任何地方和每次都是相同的。
Try editing the script and putting the line
尝试编辑脚本并放置行
LD_LIBRARY_PATH=/wherever/it/needs/to/point/to
before doing anything else. Of course, this is valid if it is your only problem. I have worked with powerbroker 2 years in the past. It is not as trivial as one might expect from such a product. If in doubt, contact the Beyond Trust's (formerly Symark) tech support. Since you are licensing the product, you must be entitled to tech support. They can tell you what you are exactly missing.
在做任何事之前。当然,如果这是你唯一的问题,这是有效的。我过去曾与powerbroker合作过2年。它并不像人们对这种产品所期望的那样微不足道。如有疑问,请联系Beyond Trust(原Symark)的技术支持。由于您要授权产品,因此您必须有权获得技术支持。他们可以告诉你你到底缺少什么。
#1
1
The problem is the environment variables set in crontab versus the ones set on your command line. They are not the same.
问题是crontab中设置的环境变量与命令行中设置的环境变量。他们不一样。
To see what you have to change: Put this in you crontab:
要查看您需要更改的内容:将此内容放入crontab中:
* * * * * set > /tmp/crontab.txt
Save it, wait for 2 -3 minuite for it to run, then remove the crontab change.
保存它,等待2 -3 minuite运行,然后删除crontab更改。
Next:
set > /tmp/myenv.txt
diff /tmp/myenv.txt /tmp/crontab.txt
will show you the differences. Make some changes to your crontab script so it has (probably) the PATH variable and LD_LIBRARY_PATH variable changes you need. You do not have to change every environment variable.
会告诉你差异。对您的crontab脚本进行一些更改,使其(可能)具有您需要的PATH变量和LD_LIBRARY_PATH变量。您不必更改每个环境变量。
#2
0
Your problem is assuming powerbroker has the same environment variables when accessed in the batch mode as it is from the interactive terminal mode.
您的问题是假设powerbroker在批处理模式下访问时具有相同的环境变量,因为它来自交互式终端模式。
Even though it is impossible to say what deficiency exists there without seeing the actual tsm_support.ksh script contents, I can bet, there are assumptions made as in LD_LIBRARY_PATH will be the same everywhere and every time.
即使在没有看到实际的tsm_support.ksh脚本内容的情况下也不可能说出存在什么缺陷,我敢打赌,在LD_LIBRARY_PATH中做出的假设在任何地方和每次都是相同的。
Try editing the script and putting the line
尝试编辑脚本并放置行
LD_LIBRARY_PATH=/wherever/it/needs/to/point/to
before doing anything else. Of course, this is valid if it is your only problem. I have worked with powerbroker 2 years in the past. It is not as trivial as one might expect from such a product. If in doubt, contact the Beyond Trust's (formerly Symark) tech support. Since you are licensing the product, you must be entitled to tech support. They can tell you what you are exactly missing.
在做任何事之前。当然,如果这是你唯一的问题,这是有效的。我过去曾与powerbroker合作过2年。它并不像人们对这种产品所期望的那样微不足道。如有疑问,请联系Beyond Trust(原Symark)的技术支持。由于您要授权产品,因此您必须有权获得技术支持。他们可以告诉你你到底缺少什么。