[OpenSER-Devel] openserctl ping

Juha Heinanen jh at tutpro.com
Fri Aug 24 17:36:23 CEST 2007


daniel,

i got options almost working with this:

	CMD="t_uac_dlg OPTIONS \"$1\" \".\" \".\" \"From: sip:daemon@$myhost"$'\r\n'"To: <$1>"$'\r\n'"Contact: sip:daemon@!!>"$'\r\n'
	echo -n $CMD > /tmp/cmd
	RET=`$CTLCMD $CMD | head -1 ` 

the problem is that \n is missing, but \r is there:

aimen:/etc/openser# hexdump -c /tmp/cmd
0000000   t   _   u   a   c   _   d   l   g       O   P   T   I   O   N
0000010   S       "   s   i   p   :   1   9   2   .   9   8   .   1   0
0000020   1   .   1   0   "       "   .   "       "   .   "       "   F
0000030   r   o   m   :       s   i   p   :   d   a   e   m   o   n   @
0000040   t   a   i   m   e   n  \r       T   o   :       <   s   i   p
0000050   :   1   9   2   .   9   8   .   1   0   1   .   1   0   >  \r
0000060       C   o   n   t   a   c   t   :       s   i   p   :   d   a
0000070   e   m   o   n   @   !   !   >  \r
0000079

so for some reason bash is converting \n to space.  if i change echo
line to

	echo -n "$CMD" > /tmp/cmd

i.e., add double quotes around $CMD, i get to /tmp/cmd also \n chars:

taimen:/etc/openser# hexdump -c /tmp/cmd
0000000   t   _   u   a   c   _   d   l   g       O   P   T   I   O   N
0000010   S       "   s   i   p   :   1   9   2   .   9   8   .   1   0
0000020   1   .   1   0   "       "   .   "       "   .   "       "   F
0000030   r   o   m   :       s   i   p   :   d   a   e   m   o   n   @
0000040   t   a   i   m   e   n  \r  \n   T   o   :       <   s   i   p
0000050   :   1   9   2   .   9   8   .   1   0   1   .   1   0   >  \r
0000060  \n   C   o   n   t   a   c   t   :       s   i   p   :   d   a
0000070   e   m   o   n   @   !   !   >  \r  \n

now i don't know how to change

	RET=`$CTLCMD $CMD | head -1 ` 

so that \n chars are not changed to spaces.  any bash experts on the list?


bash programming is a madness.  how about rewriting openserctl in some
sensible language such as php or python?

-- juha



More information about the Devel mailing list