Page 1 of 1

bug reading astguiclient.conf properly

PostPosted: Thu Oct 05, 2006 9:22 pm
by kchung
While working on a patch, I found a bug in how AST_CRON_mix_recordings_*.pl and other scripts read astguiclient.conf.

I had added this to astguiclient.conf after the PATHmonitor entry:
Code: Select all
PATHmonitor_done => /var/spool/asterisk/monitor/DONE


in AST_CRON_mix_recordings_*.pl files, i added this after line 68:
Code: Select all
if ( ($line =~ /^PATHmonitor_done/) && ($CLImonitor_done < 1) )
           {$PATHmonitor_done = $line;   $PATHmonitor_done =~ s/.*=//gi;}


The result was that $PATHmonitor got overwritten by $PATHmonitor the next time the loop was run.

Is there a better way to read the .conf file so we can use similar variable names?

My solution was to change the variable name to PATHmon_done, not as intuitive as I'd like.

PostPosted: Fri Oct 06, 2006 9:16 am
by mflorell
I'm not quite sure I understand your problem. Were you adding a DONE variable to the astguiclient.conf file?

If so you would need to just name it something different without the same prefix like "PATHDONEmonitor" and you would've had no issues.

PostPosted: Fri Oct 06, 2006 11:51 am
by kchung
In addition to the PATHmonitor variable, I added PATHmonitor_done.

What I don't understand is why the VARDB_* series of variables passed w/o problems but PATHmonitor_done didn't. Even PATHmonitordone did't.

I did change the variable to PATHmon_done, but I thought PATHmonitor_done was more intuitive.

PostPosted: Fri Oct 06, 2006 2:01 pm
by mflorell
It is filtered by the variable name, since you began the _done one with the exact same name as the monitor path one it overwrote it when it did it's loop pass.

You cannot have the root of another variable in any new variable names that are created.

PostPosted: Fri Oct 06, 2006 4:08 pm
by kchung
Ah thanks. So, if we rename PATHmonitor to PATHmonitor_raw, then PATHmonitor_done would be fine.

PostPosted: Fri Oct 06, 2006 4:16 pm
by mflorell
yep, that'll do it for you

PostPosted: Fri Oct 06, 2006 4:56 pm
by kchung
I couldnt find any good documentation on the =~ operator for perl.

PostPosted: Fri Oct 06, 2006 5:43 pm
by mflorell
That's the regular expression operator or perl. it's a way of using symbols and matchin text to see if something matches, you can also do search-and-replace with it.

http://www.troubleshooters.com/codecorn ... erlreg.htm
http://www.anaesthetist.com/mnm/perl/regex.htm