[OpenSER-Devel] openserctl ping

Edson 4lists at gmail.com
Fri Aug 24 20:17:58 CEST 2007


I think that this can help You:

	RET="$($CTLCMD $CMD | head -1)"

Edson

>-----Original Message-----
>From: devel-bounces at openser.org [mailto:devel-bounces at openser.org] On
>Behalf Of Juha Heinanen
>Sent: sexta-feira, 24 de agosto de 2007 12:36
>To: daniel at voice-system.ro
>Cc: devel at openser.org
>Subject: Re: [OpenSER-Devel] openserctl ping
>
>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
>
>_______________________________________________
>Devel mailing list
>Devel at openser.org
>http://openser.org/cgi-bin/mailman/listinfo/devel




More information about the Devel mailing list