Hi, as suggested here: http://www.openser.org/docs/scripting I'm using M4 to declare "define" in my OpenSer script.
I've an annoying issue since M4 adds some empty lines at the top of the script. If my script has any error, the logs will show me "ERROR in line 235 in openser.cfg" but that line correspondes to line 187 in my openser.cfg.m4 file, so makes it very difficult to debug.
I've read the entire doc and have no idea of how to fix it. For example, consider this simple case:
---- local.m4 ---- define(`IP',`127.0.0.1') define(`PORT' ,`5061') -----------------------
---- file.txt.m4 ---- My ip is IP and my port is PORT. --------------------------
~# m4 local.m4 file.txt.m4 > file.txt
---- file.txt ---- <-- Empty line <-- Empty line <-- Empty line <-- Empty line My ip is 127.0.0.1 and my port is 5061. ---------------------
Does someone know how to solve it? Thanks a lot.
Hello,
you can write your defines in between:
divert(-1) divert
Cheers, Daniel
On 01/21/08 00:18, Iñaki Baz Castillo wrote:
Hi, as suggested here: http://www.openser.org/docs/scripting I'm using M4 to declare "define" in my OpenSer script.
I've an annoying issue since M4 adds some empty lines at the top of the script. If my script has any error, the logs will show me "ERROR in line 235 in openser.cfg" but that line correspondes to line 187 in my openser.cfg.m4 file, so makes it very difficult to debug.
I've read the entire doc and have no idea of how to fix it. For example, consider this simple case:
---- local.m4 ---- define(`IP',`127.0.0.1') define(`PORT' ,`5061')
---- file.txt.m4 ---- My ip is IP and my port is PORT.
~# m4 local.m4 file.txt.m4 > file.txt
---- file.txt ---- <-- Empty line <-- Empty line <-- Empty line <-- Empty line My ip is 127.0.0.1 and my port is 5061.
Does someone know how to solve it? Thanks a lot.
El Domingo, 20 de Enero de 2008, Daniel-Constantin Mierla escribió:
Hello,
you can write your defines in between:
divert(-1) divert
Thanks Daniel, it works... it looks a bit "horrible" but it works :-p
divert(-1) ### IP's. divert(0)dnl define(`MY_IP', `88.95.0.110')dnl define(`ASTERISK_MEDIA_IP', `88.95.0.114')dnl dnl divert(-1) ### Routes: divert(0)dnl define(`FLAG_IN_DIALOG', `1')dnl define(`FLAG_TO_PSTN', `2')dnl define(`FLAG_NAT_CALLER', `5')dnl define(`BFLAG_NAT_CALLED', `6')dnl define(`BFLAG_NAT_PING', `7')dnl define(`BFLAG_RTPPROXY', `8')dnl dnl divert(-1) ### Flags: divert(0)dnl define(`ROUTE_DEFAULT', `1')dnl define(`ON_BRANCH_DEFAULT', `1')dnl define(`ON_REPLY_DEFAULT', `1')dnl define(`ON_FAILURE_DEFAULT', `1')dnl define(`ROUTE_REGISTER', `2')dnl
Thanks a lot.
On 01/21/08 00:52, Iñaki Baz Castillo wrote:
El Domingo, 20 de Enero de 2008, Daniel-Constantin Mierla escribió:
Hello,
you can write your defines in between:
divert(-1) divert
Thanks Daniel, it works... it looks a bit "horrible" but it works :-p
you do not need 'dnl' and lot of diverts, just include all defines, comments, empty lines in between of one set of: divert(-1) divert
It will look nicer.
Daniel
divert(-1) ### IP's. divert(0)dnl define(`MY_IP', `88.95.0.110')dnl define(`ASTERISK_MEDIA_IP', `88.95.0.114')dnl dnl divert(-1) ### Routes: divert(0)dnl define(`FLAG_IN_DIALOG', `1')dnl define(`FLAG_TO_PSTN', `2')dnl define(`FLAG_NAT_CALLER', `5')dnl define(`BFLAG_NAT_CALLED', `6')dnl define(`BFLAG_NAT_PING', `7')dnl define(`BFLAG_RTPPROXY', `8')dnl dnl divert(-1) ### Flags: divert(0)dnl define(`ROUTE_DEFAULT', `1')dnl define(`ON_BRANCH_DEFAULT', `1')dnl define(`ON_REPLY_DEFAULT', `1')dnl define(`ON_FAILURE_DEFAULT', `1')dnl define(`ROUTE_REGISTER', `2')dnl
Thanks a lot.
El Domingo, 20 de Enero de 2008, Daniel-Constantin Mierla escribió:
On 01/21/08 00:52, Iñaki Baz Castillo wrote:
El Domingo, 20 de Enero de 2008, Daniel-Constantin Mierla escribió:
Hello,
you can write your defines in between:
divert(-1) divert
Thanks Daniel, it works... it looks a bit "horrible" but it works :-p
you do not need 'dnl' and lot of diverts, just include all defines, comments, empty lines in between of one set of: divert(-1) divert
It will look nicer.
Yeah, you are right ;)
Anyway I do need to add a "dnl" after the final command "divert" so I put it as "divert(0)dnl". If not, "divert" command will add an empty line :(
Thanks a lot.
El Domingo, 20 de Enero de 2008, Iñaki Baz Castillo escribió:
---- local.m4 ---- define(`IP',`127.0.0.1') define(`PORT' ,`5061')
---- file.txt.m4 ---- My ip is IP and my port is PORT.
~# m4 local.m4 file.txt.m4 > file.txt
---- file.txt ---- <-- Empty line <-- Empty line <-- Empty line <-- Empty line My ip is 127.0.0.1 and my port is 5061.
Ops, just now I've discovered the "dnl" option and an explanation: "Another problem with m4 is that it replaces its commands with empty lines."
So I could solve partially the problem with this:
---- local.m4 ---- define(`IP',`127.0.0.1')dnl define(`PORT' ,`5061')dnl -----------------------
But the problem still occurs if I want to include comments in the local.m4 file as:
---- local.m4 ---- # Server data: <-- This will add an empty line. define(`IP',`127.0.0.1')dnl define(`PORT' ,`5061')dnl -----------------------