Operating System - HP-UX
1753885 Members
7572 Online
108809 Solutions
New Discussion юеВ

Background Job Completion Getting Written Into Variables In CSH

 
SOLVED
Go to solution
Ann Harrold
New Member

Background Job Completion Getting Written Into Variables In CSH


Hi,

I am running some CSH scripts that submit several jobs to the background. I start these scripts using -x -v and put the output to a log file. I notice that occassionally, certain variables are getting set with the job completion messages. It seems to be related to using eval echo. Has anyone seen this before? Any suggestions on how to work around this? Here is a sample failure below. In this case I am trying to set tmp2_count equal to $count24 which is 001. However, when I echo out $tmp2_count, it has some strange status message.

Thanks!
Ann

set tmp2_count = ( `eval echo \$count$test_number` )
set tmp2_count = ( `eval echo \$count$test_number` )
eval echo $count24
echo $count24
echo 001
echo $tmp2_count
echo Done csh -v -x /user_space/accounts/test/ 001
7 REPLIES 7
Michael Steele_2
Honored Contributor

Re: Background Job Completion Getting Written Into Variables In CSH

May be related to 'noglob' being on, make sure that its off; 'set +o noglob'.

What is 'set -o' from the command line?

# set -o
Current option settings
allexport off
bgnice on
emacs off
errexit off
gmacs off
ignoreeof off
interactive on
keyword off
markdirs off
monitor on
noexec off
noclobber off
noglob off
nolog off
nounset off
privileged off
restricted off
trackall off
verbose off
vi on
viraw off
xtrace off

Also, try or 'set -o xtrace' to debug at the top of your script. Turn off with 'set +o xtrace'.
Support Fatherhood - Stop Family Law
Ann Harrold
New Member

Re: Background Job Completion Getting Written Into Variables In CSH


Thanks so much for the reply. I just reran my script after doing the following

unset noglob

This is cshell, so the set -o/+o doesn't work. But, unfortunately, I am still seeing this issue with this setting. Any other suggestions would be most appreciated.

Thanks!
Ann

Mike Stroyan
Honored Contributor

Re: Background Job Completion Getting Written Into Variables In CSH

You really shouldn't need to run a subshell to make the assignment. You can eval the set command-

eval set tmp2_count=\$count$test_number
Ann Harrold
New Member

Re: Background Job Completion Getting Written Into Variables In CSH


Thanks for the last suggestion, but I do have some other cases where I am not setting a variable but rather testing for some condition and this error occurs. I am including a complete script below which replicates the problem on my system. While the code looks terrible, if you get the timing right, you will get the following error. Thanks again for all the suggestions.

Ann

@ i=0
while ($i < 500)
csh -x -v /scratch2/husp/foo/bogus_script.csh >>&! bogus.txt &
set count = $i
set test_number = 1
set count = `$Sitp_code/Sitp_C_utilities.EXE pad cnt $count`
set count$test_number = $count
if ( `eval echo \$count$test_number` != -1) then
echo foo
endif
if ( `eval echo \$count$test_number` != -1) then
echo foo
endif
if ( `eval echo \$count$test_number` != -1) then
echo foo
endif
@ i++
end


Where bogus_script.csh just increments a variable from 0 to 80 then exits. The error message I get is the following:

if ( `eval echo \$count$test_number` != -1 ) then
if ( `eval echo \$count$test_number` != -1 ) then
eval echo $count1
echo $count1
echo 000
`eval echo \$count$test_number`: Ambiguous.
[1] +Exit 1 csh -x -v /scratch2/husp/foo/bogus_script.csh >>&

Mike Stroyan
Honored Contributor

Re: Background Job Completion Getting Written Into Variables In CSH

I would be inclined to use an eval to assign before the if statement to test. It's cleaner.

eval set result=\$count$test_number
if ( $result != -1) then
echo foo
endif

However, if you really want to use eval echo, then you could use "set notify" to change the way that background job completion is reported. That seems to prevent the problem.
Ann Harrold
New Member

Re: Background Job Completion Getting Written Into Variables In CSH


Thanks for the reply. I have checked the notify setting, and ran with it both set and unset and still saw these errors. I even tried directing the "Done" messages to a different file with the same results.

I am trying to replace all of my eval echo statements with eval set statements in order to test this. Some of the variables I am setting are multi-word variable. How would I do the eval set method to set these variables? For example:

eval set record = \$p$var
eval set record = $p0
set record = $p0
set record = 0 airco SUBMIT 1 10
set: Syntax error.

Thanks,
Ann
Mike Stroyan
Honored Contributor
Solution

Re: Background Job Completion Getting Written Into Variables In CSH

You need to use quoted double-quotes to handle spaces in the variable.

eval set record=\"\$p$var\"

The backslashes quote the "s so they go on to the eval command.