Summary:ASTERISK-00762: [patch] The "SystemCID" app -- submitting for Announcements and other uses.
Reporter:Steve Murphy (murf)Labels:
Date Opened:2004-01-08 14:00:06.000-0600Date Closed:2008-01-15 15:07:48.000-0600
Versions:Frequency of
Environment:Attachments:( 0) app_system.c
( 1) app_systemcid.c
( 2) diffu.app_system
( 3) diffu.app_system
Description:This app basically runs the command thru an sprintf, with
the arg of the channel->callerid:

sprintf( commandbuf, command, channel->callerid).

Then it pretty much does as system did, except it always returns 0, because in this case, I'm not interested in
the result code.

I use it in my dialplan so:

exten => 1,1,SystemCID(/usr/bin/play /var/lib/asterisk/sounds/priv-callerintros/%s.gsm&)

If the announcement file exists, it gets played. If it doesn't, it doesn't get played. Such is life. I'm using
it for announcements of the caller and the called person. Around here, this makes life very nice. I hope to able
to send these announcements over the network to other
systems, to use their speakers for the PA system.
Hope it's useful enough to include in the Asterisk release.
Comments:By: Brian West (bkw918) 2004-01-09 07:22:47.000-0600

This app isn't needed you just modified the system command which can do the same thing as this.

System(usr/bin/play /var/lib/asterisk/sounds/priv-callerintros/${CALLERIDNUM}.gsm&)


By: Steve Murphy (murf) 2004-01-09 07:43:17.000-0600

Almost, that's true. Here's the differences:

1. If you include a %s in the command, it will be replaced with the phone
  number from the callerid. So, if the person calling is from 800-872-9234,
  the '%s' will be replaced with 8008729234, something you can't do with
  System at all.
2. This routine doesn't return anything but 0. The return of a -1 from System
  will close the channel if I tried the same thing with System. It really
  doesn't care what the result of the command was.

By: Brian West (bkw918) 2004-01-09 20:33:42.000-0600

then lets add some options to allow app_system to work in a similar way instead of adding an app that duplicates so much code.

By: Steve Murphy (murf) 2004-01-10 03:06:39.000-0600

Not a bad idea at all. I've thought along the same line. Do you intend to do
it, or should I?

By: Brian West (bkw918) 2004-01-10 16:56:02.000-0600

Go for it..  If you can complete the mod and its tested by more than two people in #asterisk it might make it before the 0.7.0 release monday.


By: Steve Murphy (murf) 2004-01-10 18:15:35.000-0600

There. If the last 2 chars of the arg of a normal System(cmd)
are "|0", they will be erased, and the System command will always
return a 0, irregardless of what the cmd is.

I've tested this with the

System(usr/bin/play /var/lib/asterisk/sounds/priv-callerintros/${CALLERIDNUM}.gsm&)

and it works correctly.


By: Brian West (bkw918) 2004-01-10 18:29:50.000-0600

System(/usr/bin/play /var/lib/asterisk/sounds/priv-callerintros/${CALLERIDNUM}.gsm&|0)

Is that what you mean?

By: Brian West (bkw918) 2004-01-10 18:30:32.000-0600

also can you attach a diff -u

diff -u app_system.c.orig app_system.c > app_system.diff

then attach that.

By: Steve Murphy (murf) 2004-01-10 21:56:30.000-0600

Yes. I meant to include the |0; but my fumble fingers skipped it and my
feeble eyesight missed the error. Sorry about the confusion.

I have added the diff -u file also.


By: Steve Murphy (murf) 2004-01-11 09:21:36.000-0600

One last note: I have just uploaded the diff -u again; why? Because I
forgot to document the new option in the "descrip" string in the source.
My newly uploaded diffs take care of this oversight. Sorry!

By: mlh (mlh) 2004-03-27 14:57:36.000-0600

Resolved...no comments

By: Steve Murphy (murf) 2004-09-17 20:49:49

Uh, I guess I could interpret the closing of this bug as a
rejection; but because it was closed without comment, I am "appealing" the closure, and ask for a moment of reconsideration. If you run a system program, and it returns a non-zero result code, it aborts your context when system returns -1.

Rather than write a wrapper (which in some cases doesn't seem to help),
this tweak is backwards compatible, works the same as usual if no action is taken by existing users.

Anyone else out there who might think this a desirable option?

By: Steve Murphy (murf) 2004-09-17 20:51:33

Just added a new version to track a change made a while back to

By: Mark Spencer (markster) 2004-09-18 10:11:15

See newly added "TrySystem", that, in combination with variable ${CALLERIDNUM} should handle your example.  I decided not to make it a new wrapper and not an option to the existing System app because | is often used in a system string.

By: Digium Subversion (svnbot) 2008-01-15 15:07:48.000-0600

Repository: asterisk
Revision: 3806

U   trunk/apps/app_system.c

r3806 | markster | 2008-01-15 15:07:48 -0600 (Tue, 15 Jan 2008) | 2 lines

Add "TrySystem" variation to System (bug ASTERISK-762)