Help in call file

Hi Guys,
I need a little help regarding a call file I want to execute every 1 minute using crontab
I created this sh file

#!/bin/sh
echo -e “Channel: SIP/207\nContext: remind\nExtension: s” > /tmp/test.call
mv /tmp/test.call /var/spool/asterisk/outgoing

When I run manually on the command line the call is processed without an error. But when I schedule it using crontab

          • /home/myfolder/scripts/test.sh

I get this error on asterisk

[Jul 26 08:15:01] WARNING[2100]: pbx_spool.c:290 parse_line: Unknown keyword ‘-e Channel’ at line 1 of /var/spool/asterisk/outgoing/test.call
[Jul 26 08:15:01] WARNING[2100]: pbx_spool.c:327 apply_outgoing: At least one of app or extension must be specified, along with tech and dest in file /var/spool/asterisk/outgoing/test.call
[Jul 26 08:15:01] WARNING[2100]: pbx_spool.c:517 scan_service: Invalid file contents in /var/spool/asterisk/outgoing/test.call, deleting

Any help would be appreciated. Thanks in Advanced

I haven’t never been a fan of call files, but assuming you don’t want to use all the option you have with the call file, and is just originate a call every 1 minute. You can schedule the same task with

asterisk -x "originate " command

Hi @ambiorixg12 Thanks for the reply,
Actually, test.call file is just part of a bigger sh file created. What I’m trying to do is have my linux server read a MySQL table for newly inserted columns every minute then if it found a new entry, it will execute some scripts off that MySQL table then have it create a call file to be executed by asterisk based on the touch date and time.

Did you verify the content of test.call file looks like the e letter is added within the channel value

@ambiorixg12 Yes, what I currently don’t understand is when I manually execute the sh file in the command line is creates the call file correctly, But when it is configured to run via crontab, ‘-e’ is added before the ‘Channel: SIP/207’ line

Well the The ‘ -e ‘ option in Linux acts as interpretation of escaped characters that are backslashed. But looks here all after the echo command is added

As a workaround you can try adding the call files parameters on more than one echo to avoid the e option.

  1. Please wrap code and console snippets in ‘preformatted text’ tags so the forum does not mung your post by eating significant characters, change quotes to ‘smart quotes’ etc.

  2. ‘sh’ does not understand ‘-e.’

  3. If you break your single echo into multiple statements it will be easier to debug and maintain.

  4. If you create your call file in /tmp/ and /tmp/ is not on the same file system as your outgoing spool directory, you introduce the possibility of a race condition where Asterisk could process a partial file. One way to eliminate it would be to create a ‘tmp’ directory in the outgoing spool directory and then ‘mv’ the file to the outgoing spool directory.

  5. If you enable ‘archive’ you can look at the call file after processing. It will be in the ‘outgoing_done’ directory. This also helps when things don’t work.

I think you mean ‘rows.’

I’ve never used ‘originate’ in an application.

The simplicity of a single command has appeal, certainly for debugging or hacking out a quick test, but call files seem more ‘featureful.’ With the originate command, can you:

  1. Specify the caller ID?
  2. Specify retries?
  3. Specify the priority?
  4. Set variables?

I know you could specify a local channel and handle this kind of stuff there, but sometimes you need to change these things on a call-by-call basis.

Is my understanding correct?

Have you taken a look at the Originate documentation

  • c - The caller ID number to use for the called channel. Default is the current channel’s Caller ID number.
  • n - The caller ID name to use for the called channel. Default is the current channel’s Caller ID name.
  • v ( var1 ) - A series of channel variables to set on the destination channel.
    • var1 [^ var1 …]
      • name
      • value

As you already said you can do this change using local channels

I was asking about the CLI originate command that you proposed, not the originate() application. The originate() application appears to be much more featureful than the CLI command.

If using the command

 channel originate <tech/data> extension [<exten>@][<context>] 

Local channels are needed to unlock the real power

As of Asterisk 18.4, #1 and #4 are now possible with the Originate application.
I’ve now converted 90%+ of my call files to Originate, only ones left are things that are for the future or with retries.

The CLI originate command was proposed as an alternative to call files, not the originate application.

Right, but previously, they were both pretty equally lacking in features. I think only the AMI originate allowed these.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.