VoIP Mailing List Archives
Mailing list archives for the VoIP community |
|
View previous topic :: View next topic |
Author |
Message |
avi at avimarcus.net Guest
|
Posted: Thu Oct 28, 2021 11:14 am Post subject: [Freeswitch-users] Trying to get short hostname |
|
|
System doesn't listen to stdout, it's only for running the command.
On Thu, Oct 28, 2021, 6:22 PM Antony Stone <Antony.Stone@freeswitch.open.source.it (Antony.Stone@freeswitch.open.source.it)> wrote:
Quote: | Hi.
I'm using FreeSwitch 1.10.7 as a client registering to other PBXs as well as a
SIP server itself.
I am setting the user-agent string in the SIP profile, such as:
<param name="user-agent-string" value="FS $${CFGver} $${hostname}"/>
The variable $${CFGver}} is a version string I'm definiing in vars.xml
This is working, but it gives me the FQDN of the machine as $${hostname}} and
I really only want the machine name without the domain.
I've found
https://freeswitch.org/confluence/display/FREESWITCH/Regular+Expression and
https://freeswitch.org/confluence/display/FREESWITCH/mod_dptools:+regex and
I've tried to use them to cut the domain off the value of $${hostname} but with
no success:
In vars.xml:
<X-PRE-PROCESS cmd="set" data="shorthostname=${regex($${hostname}|([^\.]*).*|
%1)}"/>
This results in the variable shorthostname being assigned the value:
%{regex(abcd.efgh.tld|([^\.]*).*|%1)}
where abcd.efgh.tld is the server's FQDN.
Instead of doing that in vars.xml and creating the variable shorthostname, I
tried putting the regex into the SIP profile:
<param name="user-agent-string" value="FS $${CFGver} ${regex($${hostname}|
([^\.]*).*|%1)}"/>
This ends up with precisely the same result. The ${regex(....)} function
simply isn't being executed.
Given that the machine's hostname is also available from the system command
"hostname -s" I decided to try that instead:
In vars.xml:
<X-PRE-PROCESS cmd="set" data="shorthostname=${system(hostname -s)}"/>
Or in the SIP profile definition:
<param name="user-agent-string" value="FS $${CFGver} ${system(hostname -s)}"/>
These both produce the output:
FS 0.65 ${system(hostname -s)}
In other words, the ${system(....)} command isn't working any more than
${regex(....)} did.
What am I doing wrong please?
How can I get the machine's short hostname into a user-agent string for
registration to a server?
Thanks,
Antony.
--
Perfection in design is achieved not when there is nothing left to add, but
rather when there is nothing left to take away.
- Antoine de Saint-Exupery
Please reply to the list;
please *don't* CC me.
_________________________________________________________________________
The FreeSWITCH project is sponsored by SignalWire https://signalwire.com
Enhance your FreeSWITCH install with disruptive priced SMS and PSTN services.
Build your next product on our scalable cloud platform.
Join our online community to chat in real time https://signalwire.community
Professional FreeSWITCH Services
sales@freeswitch.com (sales@freeswitch.com)
https://freeswitch.com
Official FreeSWITCH Sites
https://freeswitch.com/oss
https://freeswitch.org/confluence
https://cluecon.com
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
https://freeswitch.com |
|
|
Back to top |
|
|
Antony.Stone at freesw... Guest
|
Posted: Thu Oct 28, 2021 11:18 am Post subject: [Freeswitch-users] Trying to get short hostname |
|
|
Hi.
I'm using FreeSwitch 1.10.7 as a client registering to other PBXs as well as a
SIP server itself.
I am setting the user-agent string in the SIP profile, such as:
<param name="user-agent-string" value="FS $${CFGver} $${hostname}"/>
The variable $${CFGver}} is a version string I'm definiing in vars.xml
This is working, but it gives me the FQDN of the machine as $${hostname}} and
I really only want the machine name without the domain.
I've found
https://freeswitch.org/confluence/display/FREESWITCH/Regular+Expression and
https://freeswitch.org/confluence/display/FREESWITCH/mod_dptools:+regex and
I've tried to use them to cut the domain off the value of $${hostname} but with
no success:
In vars.xml:
<X-PRE-PROCESS cmd="set" data="shorthostname=${regex($${hostname}|([^\.]*).*|
%1)}"/>
This results in the variable shorthostname being assigned the value:
%{regex(abcd.efgh.tld|([^\.]*).*|%1)}
where abcd.efgh.tld is the server's FQDN.
Instead of doing that in vars.xml and creating the variable shorthostname, I
tried putting the regex into the SIP profile:
<param name="user-agent-string" value="FS $${CFGver} ${regex($${hostname}|
([^\.]*).*|%1)}"/>
This ends up with precisely the same result. The ${regex(....)} function
simply isn't being executed.
Given that the machine's hostname is also available from the system command
"hostname -s" I decided to try that instead:
In vars.xml:
<X-PRE-PROCESS cmd="set" data="shorthostname=${system(hostname -s)}"/>
Or in the SIP profile definition:
<param name="user-agent-string" value="FS $${CFGver} ${system(hostname -s)}"/>
These both produce the output:
FS 0.65 ${system(hostname -s)}
In other words, the ${system(....)} command isn't working any more than
${regex(....)} did.
What am I doing wrong please?
How can I get the machine's short hostname into a user-agent string for
registration to a server?
Thanks,
Antony.
--
Perfection in design is achieved not when there is nothing left to add, but
rather when there is nothing left to take away.
- Antoine de Saint-Exupery
Please reply to the list;
please *don't* CC me.
_________________________________________________________________________
The FreeSWITCH project is sponsored by SignalWire https://signalwire.com
Enhance your FreeSWITCH install with disruptive priced SMS and PSTN services.
Build your next product on our scalable cloud platform.
Join our online community to chat in real time https://signalwire.community
Professional FreeSWITCH Services
sales@freeswitch.com
https://freeswitch.com
Official FreeSWITCH Sites
https://freeswitch.com/oss
https://freeswitch.org/confluence
https://cluecon.com
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
https://freeswitch.com |
|
Back to top |
|
|
Antony.Stone at freesw... Guest
|
Posted: Mon Nov 01, 2021 5:29 pm Post subject: [Freeswitch-users] Trying to get short hostname |
|
|
On Thursday 28 October 2021 at 17:29:22, Avi Marcus wrote:
Quote: | System doesn't listen to stdout, it's only for running the command.
|
Er, sorry?
https://freeswitch.org/confluence/display/FREESWITCH/mod_dptools:+system
And anyway, what's wrong with my regex?
Antony.
Quote: | On Thu, Oct 28, 2021, 6:22 PM Antony Stone wrote:
Quote: | Hi.
I'm using FreeSwitch 1.10.7 as a client registering to other PBXs as well
as a SIP server itself.
I am setting the user-agent string in the SIP profile, such as:
<param name="user-agent-string" value="FS $${CFGver} $${hostname}"/>
The variable $${CFGver}} is a version string I'm definiing in vars.xml
This is working, but it gives me the FQDN of the machine as $${hostname}}
and I really only want the machine name without the domain.
I've found
https://freeswitch.org/confluence/display/FREESWITCH/Regular+Expression
and
https://freeswitch.org/confluence/display/FREESWITCH/mod_dptools:+regex
and I've tried to use them to cut the domain off the value of $${hostname}
but with no success:
In vars.xml:
<X-PRE-PROCESS cmd="set"
data="shorthostname=${regex($${hostname}|([^\.]*).*|
%1)}"/>
This results in the variable shorthostname being assigned the value:
%{regex(abcd.efgh.tld|([^\.]*).*|%1)}
where abcd.efgh.tld is the server's FQDN.
Instead of doing that in vars.xml and creating the variable
shorthostname, I tried putting the regex into the SIP profile:
<param name="user-agent-string" value="FS $${CFGver}
${regex($${hostname}| ([^\.]*).*|%1)}"/>
This ends up with precisely the same result. The ${regex(....)} function
simply isn't being executed.
Given that the machine's hostname is also available from the system
command "hostname -s" I decided to try that instead:
In vars.xml:
<X-PRE-PROCESS cmd="set" data="shorthostname=${system(hostname -s)}"/>
Or in the SIP profile definition:
<param name="user-agent-string" value="FS $${CFGver} ${system(hostname
-s)}"/>
These both produce the output:
FS 0.65 ${system(hostname -s)}
In other words, the ${system(....)} command isn't working any more than
${regex(....)} did.
What am I doing wrong please?
How can I get the machine's short hostname into a user-agent string for
registration to a server?
Thanks,
Antony.
|
|
--
My life is going completely according to plan.
I do sometimes wish it had been *my* plan, though.
Please reply to the list;
please *don't* CC me.
_________________________________________________________________________
The FreeSWITCH project is sponsored by SignalWire https://signalwire.com
Enhance your FreeSWITCH install with disruptive priced SMS and PSTN services.
Build your next product on our scalable cloud platform.
Join our online community to chat in real time https://signalwire.community
Professional FreeSWITCH Services
sales@freeswitch.com
https://freeswitch.com
Official FreeSWITCH Sites
https://freeswitch.com/oss
https://freeswitch.org/confluence
https://cluecon.com
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
https://freeswitch.com |
|
Back to top |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|