Re: Recursion too deep error. (8334 Views)
Reply
Occasional Contributor
raj0105
Posts: 8
Registered: ‎06-03-2009
Message 1 of 7 (8,334 Views)

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

Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,879
Registered: ‎03-06-2006
Message 2 of 7 (8,334 Views)

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.
Please use plain text.
Occasional Contributor
raj0105
Posts: 8
Registered: ‎06-03-2009
Message 3 of 7 (8,334 Views)

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
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,879
Registered: ‎03-06-2006
Message 4 of 7 (8,334 Views)

Re: Recursion too deep error.

>How could I stop this function?

Have you tried creating a log1 script instead of a function?
Please use plain text.
Occasional Contributor
raj0105
Posts: 8
Registered: ‎06-03-2009
Message 5 of 7 (8,334 Views)

Re: Recursion too deep error.

Hi Dennis,

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

Raj
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,879
Registered: ‎03-06-2006
Message 6 of 7 (8,334 Views)

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.
Please use plain text.
Occasional Contributor
raj0105
Posts: 8
Registered: ‎06-03-2009
Message 7 of 7 (8,334 Views)

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
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation