Asterisk CLI multiple commands?

Is it possible to execute 2 or more commands in one CLI remote connection with -rx option? :thinking:

For example:
asterisk -rx "core show version; core show channels; sip set debug off"
Which means 1 connection, 3 commands and 3 outputs.

Instead of:
asterisk -rx "core show version"; asterisk -rx "core show channels"; asterisk -rx "sip set debug off"
Which means 3 connections with single command.

Nope. 1 command per invocation.

Why is it an issue? What are you trying to accomplish?

(And just an FYI, the ‘r’ in ‘-rx’ is redundant. ‘-x’ implies ‘-r’)

Thank you for answer! It’s not an issue.

I made mistake by using linux
nohup asterisk -rx "channel originate bla bla bla" > /dev/null 2>&1 &
command in my application for ultra fast calls bulks. Because I didn’t know about CLI connection limits (only 128 active connections).

Now I have to use AMI for this, but I’m lazy and just wanted for fast solution :rofl:
If I remove nohup it will fix problem, but calls will originate not so fast in cycle (because it will connect to cli, then execute command, and will wait for output).
I don’t want to use old method - callfiles. AMI is the best way for this in my opinion.

Why no love for call files? They have some advantages over originate and AMI – and some disadvantages :slight_smile:

Partial file reading, Creating a lot of files in one folder, Then move them to another folder - It is cringe in 2k21 :grin:

I’ll try to redesign my app code to use AMI instead of asterisk -x in weekends. I hope I can overcome my laziness.

If I can’t - I have an idea: originate some weird command like
channel originate Local\number1*number2*number3*number999@my-super-context/n application someapplication.
And in my-super-context try to cut numbers with ${CUT} by * symbol and dial each of them with While dialplan function :thinking:

Another idea:

  1. use asterisk -r command in my application
  2. wait for some output
  3. spam originate commands without any waiting for output

Second idea is not so good.

If you are creating the files in a directory on the same file system as your spool directory this should not be a issue. If the file systems are different, mv becomes cp and you can get partial files.

Just out of curiosity, how many calls are you trying to initiate at once?

Maximum - 300 calls initialize in 1 second.

I have a SIP trunk with 300 concurrent calls availability.
Before making a bulk, my application first checks the number of free channels in SIP trunk (off course with asterisk -rx + grep + sed command) .

Usually in my app ~3000-10000 calls are made per day + SMS.
It’s not only for notifying, users are using a speech recognition + synthesize + another dificult call scenarios.

If user create some bulks with 10000 numbers, my app have to call them ASAP.

While I had a trunk with 100 simultaneous calls, there were no problems. After the provider increased the channels to 300, problems began with nohup+asterisk -rx :face_with_symbols_over_mouth:

Now instead of resting on the weekend I have to rewrite the code to AMI or call files.

BTW how fast is AMI originating and call files? Will it handle 300 calls initialize in 1 second?

AMI is probably your best choice. I’ve never tried originating a bunch of calls via AMI.

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