Getting error for System application

I am getting an error when system application try to executes.

[CONFERENCE-ADMIN]
exten => 1111,1,Answer()
exten => 1111,2,playback(beep)
exten => 1111,n,System(cp /usr/local/vijay/call/playback.call /usr/local/data/var/spool/asterisk/outgoing/)
exten => 1111,n,Verbose(2, starting the conference)
exten => 1111,n,ConfBridge(1,default_bridge,admin_user)
exten => 1111,n,Verbose(2, Ending the conference)

It’s difficult to read images of logs.

The undefined symbol almost certainly mean that the System application wasn’t built from the same configuration, and possibly version, as the rest of Asterisk. References to cap_from_text are conditionally compiled, so their use presumably depends on what was on the system when ./configure was run.

Not related to your problem, but…

It’s recommended to use mv instead of cp since mv is ‘atomic’ – at least when the source and the destination are on the same filesystem.

Using ‘same = n’ beats the heck out of repeating extensions and priorities.

I think it needs cp followed by mv. cp because the OP is reusing a fixed file, and mv to ensure that the whole file arrives before it becomes visible. Obviously you need to meet he conditions for atomicity, so the destination of the cp needs to be on the same file system as that for the mv.

Logs are as below

– Executing [1111@WCD-APP:3] System(“SIP/1001-00000000”, “mv /usr/local/vijay/call/playback.call /usr/local/data/var/spool/asterisk/outgoing/”) in new stack
asterisk: symbol lookup error: asterisk: undefined symbol: cap_from_text
[Jun 24 06:37:31] WARNING[977][C-00000000]: app_system.c:148 system_exec_helper: Unable to execute ‘mv /usr/local/vijay/call/playback.call /usr/local/data/var/spool/asterisk/outgoing/’
== Spawn extension (WCD-APP, 1111, 3) exited non-zero on ‘SIP/1001-00000000’

Hi, What I have to do to resolve this problem? I am new to asterisk, can you guide me for same?

can you run this command in bash cli ?

Yes

[root@CCG ~]# cp /usr/local/vijay/call/*.call /usr/local/data/var/spool/asterisk/outgoing/
[root@CCG ~]#

some command can’t run with asterisk role
can you try create some bash file, set permission full for asterisk user, and run command System(bash xxx.sh)

I tried to run simple bash file hello.sh with TrySystem and as a result, it shows FAILURE.

Can you tell me how to set full permission for asterisk user

[root@CCG /usr]# ./hello.sh
Hello World
[root@CCG /usr]#

@david551 @voip.com.vn

I also checked for SHELL application, It is working perfectly ! Only thing is that i need to set dummy variable namely GLOBAL_WCD_CIP

exten => 1111,n,Set(GLOBAL(Global_WCD_CIP)=${SHELL(cp /usr/local/vijay/call/*.call /usr/local/data/var/spool/asterisk/outgoing/)})
;exten => 1111,n,Set(GLOBAL(Global_WCD_CIP)=${SHELL(/usr/hello.sh)})
exten => 1111,n,Verbose(2,${Global_WCD_CIP})

why not try AGI :

/var/lib/asterisk/agi-bin/test.sh

in test.sh
#!/bin/bash
result =$(cp … )

in dialplan

exten => X,1,AGI(test.sh) 
exten => X,2,Verbose(result is: ${result})

Your script is not an AGI. It does not comply with the AGI protocol.

Setting a shell variable does not set a channel variable.

1 Like

I miss some command, pls try as below:
/var/lib/asterisk/agi-bin/test.sh

in test.sh
#!/bin/bash
result =$(cp … )
echo “SET VARIABLE result “$result””

in dialplan

exten => X,1,AGI(test.sh) 
exten => X,2,Verbose(result is: ${result})
1 Like

(Please wrap code snippets in preformatted text tags so the forum does not mung special characters like quotes.)

Still ‘not an AGI’ in that it does not comply with the AGI protocol.

It may work in this limited ‘1 shot’ example, but it is a bad example.

  1. It does not read the AGI environment passed by Asterisk.
  2. It does not read the response to the ‘set variable’ request.
  3. There is an extraneous space in the assignment to the Bash variable ‘result.’
  4. The command substitution should be quoted.
  5. The Bash variable ‘result’ is improperly quoted – resulting in only the first ‘word’ being assigned to the Asterisk channel variable ‘result.’

While Bash can be used to write an AGI it would not be my first choice. Personally, I’d use C or one of the ‘P’ languages.

My guess would be you are missing the system library that contains cap_from_text().

Are you cross-compiling, building from source, or installing from packages?

What version and flavor of OS?

What version of Asterisk?

  1. None of the quotes are the U+0022, Quotation Mark, character that Asterisk recognizes.

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