This single line of code in a sh script file
causes the script to prematurely exit with an exit code of 1 (i.e. an error) if the script is run with the -e option (e.g. if
is executed near the top of the script file).
Alternatively, you can execute it like
and prove that that top line is the offender.
The top command calculates Cpu(s) by looking at the change in CPU time values between samples. When you first run it, it has no previous sample to compare to, so these initial values are the percentages since boot. It means you need at least two loops or you have to ignore summary output from the first loop. This is problem for example for batch mode. There is a possible workaround if you define the CPULOOP=1 environment variable. The top command will be run one extra hidden loop for CPU data before standard output.
So, naturally I tried
as well as
but both of those still fail.
Does anyone know what is going on? Should I file a bug report?
Also occurs on SLES 10.1 with procps-3.2.6-18.7. Yeah, I'd go ahead and report the bug (or obtain the source code and attempt to debug it if you are so inclined).
Incidentally, you may already be aware but as a workaround you can do this to ensure your script carries on its merry way without having to turn off set -e:
Incidentally, you may already be aware but as a workaround you can do this to ensure your script carries on its merry way without having to turn off set -e:
Thats clever, and it works! It is what I use now.
I was thinking that there had to be some way to suppress the exit code, thanks.
Hi Folks -
I'm encountering an issue:
Scenario:
We have automated GL data loads utilizing FDMEE. The problem is that some of our Locations could have multiple files. I think we are running into a situation where the script is trying to name the 2 files the same name and it is bombing out.... (8 Replies)
Hello,
This porblem bugged me for some time. It is to merge different files of hundred rows to have a union with the ID as key column (kind of similar to join!) and absence with 0.
ID File1
A 1
C 3
D 4
M 6
ID File2
A 5
B 10
C 15
Z 26
ID File3
A 2
B 6
O 20
X 9
I want the output... (9 Replies)
Hi,
I am running following command: top -p <psid> | grep used
I want to send o/p of above command to some txt file but it do not break as it keeps going. How can I exit 'top -p <psid> | grep used' after certain time like 1 min or 2 mins? (1 Reply)
I have done a script and IT WORKS JUST PERFECT from command line...but in cron it has problems executing...
nawk -F"|" '
{ s=substr($104,2,18)}
{b ++s}
END { for (i in b) print i, b } ' $1 > /path/to/files/TranId_w$2
q=`cat /path/to/files/TranId_w$2 | wc -l`
echo $q >... (1 Reply)
I'm receiving an exit code 64 in our batch scheduler (BMC product control-m) executing a PERL script on UX-HP. Can you tell me where I can find a list of exit codes and their meaning. I'm assuming the exit code is from the Unix operating system not PERL. (3 Replies)
Hi,
I am working on Solaris 8 and the "intro" man page says, "Upon termination, each command returns two bytes of status, one supplied by the system and given the cause for termination, and (in the case of 'normal' termination) one supplied by the program. The former byte is 0 for normal... (2 Replies)