123. System()

Führt einen Shell-Befehl aus.

System(Befehl)

Führt durch die C-Funktion system() einen Befehl auf der Shell sh aus.

Diese Anwendung ist der TrySystem()-Anwendung sehr ähnlich, abgesehen davon, dass sie -1 zurückliefert, falls sie den Systembefehl nicht ausführen kann, wohingegen die TrySystem()-Anwendung stets 0 zurückliefert.

Setzt die Channelvariable SYSTEMSTATUS auf SUCCESS (erfolgreich ausgeführt), FAILURE (konnte nicht ausgeführt werden) oder (undokumentiert) auf APPERROR (Befehl ausgeführt aber mit Exit-Code ungleich 0).

exten => s,1,System(echo '${DATETIME} - ${CALLERID} - ${CHANNEL}' >> /var/log/asterisk/anrufe)

Siehe auch. Abschnitt 126, „TrySystem()

[Anmerkung]Anmerkung

Als Alternative kann die Applikation Backticks() oder Funktion BACKTICKS() aus dem Modul app_backticks[112] verwenden, mit denen man auch die Ausgabe des Befehls erhält.

[Anmerkung]Anmerkung

Interner Hilfetext zu dieser Applikation in Asterisk 1.4: 

  -= Info about application 'System' =- 

[Synopsis]
Execute a system command

[Description]
  System(command): Executes a command  by  using  system(). If the command
fails, the console should report a fallthrough. 
Result of execution is returned in the SYSTEMSTATUS channel variable:
   FAILURE  Could not execute the specified command
   SUCCESS  Specified command successfully executed

Old behaviour:
If the command itself executes but is in error, and if there exists
a priority n + 101, where 'n' is the priority of the current instance,
then  the  channel  will  be  setup to continue at that priority level.
Note that this jump functionality has been deprecated and will only occur
if the global priority jumping option is enabled in extensions.conf.

Differenz zum internen Hilfetext in Asterisk 1.2: 

- keine - 

$Revision:473 $

Beta-Version!

2.0 Entwickler-Version des Asterisk Buches. Die 1.0 stabile Version ist natürlich noch online. Die 2.0er Version enthält viele Neuerungen, ist aber noch nicht 100% fehlerfrei. Im Zweifelsfall bitte auf die 1.0er Version gehen.

Bitte melden Sie Fehler und Feedback zur neuen 2.0er Version per E-Mail an den Autor.

Asterisk-Tag.org 2008

Auf der Asterisk-Tag.org Webseite finden Sie die Folien und Videos der Vorträge.

Werbung