BladeSystem Forums have moved here
To make BladeSystem information easier to find, we have moved the BladeSystem forums here, to Servers and Operating Systems.
Languages and Scripting
Showing results for 
Search instead for 
Do you mean 

Recursion too deep error.

Occasional Contributor

Recursion too deep error.

Hi experts,

I got script to log user keystroke to a file.
I put that script in /etc/profile.
Everything works fine but some times while user getting loged in to system it gives error continuously as below.
"profile[4]: log1: recursion too deep."
and my script is:
HISTFILE=$HOME/.sh_history
export HISTFILE
ln=`logname`
lr=`last -R | head -1 | awk '{ print $3}'`
function log1
{

xr=$(fc -ln -0 | head -1)
z=`logger -p local3.info echo "$ln@$lr PWD $PWD $xr"`
}

trap log1 DEBUG

I hope this is happening because same function(log1) getting run multiple times when /etc/profile is getting executed.

Kindly help (Will assign points)

Raj

6 REPLIES
Acclaimed Contributor

Re: Recursion too deep error.

>I hope this is happening because same function(log1) getting run multiple times

You may have to cancel that trap inside log1. Or put log1 in a separate script.
Occasional Contributor

Re: Recursion too deep error.

Hi,
Thanks for reply.

How could I stop this function kindly help.

But it should run after each key stroke.


Kindly help.

Chandra
Acclaimed Contributor

Re: Recursion too deep error.

>How could I stop this function?

Have you tried creating a log1 script instead of a function?
Occasional Contributor

Re: Recursion too deep error.

Hi Dennis,

How can I do that could you pls help me on this.

Raj
Acclaimed Contributor

Re: Recursion too deep error.

>How can I do that?

That may not help since "trap" is still set. You could try turning it off in log1.

Otherwise you would need to copy your log1 function to a script called log1, move all variable settings too. And remove the "function log1 {}" around the body.
Occasional Contributor

Re: Recursion too deep error.

HI Dennis,

Thanks again for response.

As per your suggestion I have traped function as script.

At present I have not find any issues.

Let me keep under obeservation this for two weeks.

Raj