Passer une variable php a un script bash
xunil2003
Messages postés
830
Statut
Membre
-
Flachy Joe Messages postés 2303 Statut Membre -
Flachy Joe Messages postés 2303 Statut Membre -
Bonjour,
Je voudrai faire passer des variable php d'un formulaire à un script bash ??
Le formulaire php
Le script bash
/var/log/apache2/error.log
C'est tout nikel, mais j'ai un problème de droit .
Comment puis-je faire ?
Merci.
Je voudrai faire passer des variable php d'un formulaire à un script bash ??
Le formulaire php
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
<title>Appel de réveil Asterisk</title>
</head>
<body>
<div align="center">
Appel de reveil<br>
<br>
Pour les chiffres inferieur a 10 mettre un zèro (0) avant.<br>
A la date et l'heure demmandé, le téléphone sonnera 4 fois, sur le poste indiqué. Chaque sonnerie duree 20 secondes environ.<br>
La connection sip doit resté en marche, au poste indiqué, si le poste est un téléphone mobile, vérifier l'état de la baterie.<br>
Une fois valider, l'appel de réveil ne pourra pas être annulé<br>
<p>
<?php
if(isset($_POST["envoyer"])){
$NUMERO = (htmlspecialchars($_POST['numero']));
$JOUR = (htmlspecialchars($_POST['jour']));
$MOIS = (htmlspecialchars($_POST['mois']));
$ANNEE = (htmlspecialchars($_POST['annee']));
$HEURES = (htmlspecialchars($_POST['heures']));
$MINUTES = (htmlspecialchars($_POST['minutes']));
$HORAIRE = "$HEURES$MINUTES";
//$HORAIRE = "$MINUTES$HEURES";
echo $HORAIRE;
$result = shell_exec ('/var/lib/asterisk/agi-bin/reveil.agi '.$NUMERO.' '.$JOUR.' '.$MOIS.' '.$ANNEE.' '.$HORAIRE);
if($result) {
echo "<p align='center' style='color:green;'>"."<strong>Appel de réveil validé</strong>"."</p>";
echo "<p align='center' style='color:green;'>"."<strong>En date du '.$JOUR.'/'.$MOIS.'/'.$ANNEE.' à '.$HEURES.':'.$MINUTES.'</strong>"."</p>";
echo "<p align='center' style='color:green;'>"."<strong>Le téléphone sonnera 4 fois avec chaque sonnerie une durée de 20 secondes Environ.</strong>"."</p>";
echo "<p align='center' style='color:green;'>"."<strong>L'annulation de l'appel de réveil est impossible</strong>"."</p>";
}
//echo "non Votre projet à bien été créé.\n";
echo "<p align='center' style='color:red;'>"."<strong>Erreur : impossible de valider l'appel de réveil !</strong>"."</p>";
}
?>
<form action="" method='post'>
<table style="text-align: left; width: 100px;" border="0"
cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top;">Poste<br>
</td>
<td style="vertical-align: top;"><select name="numero" value="">
<option value="">------- SELECTIONNEZ UN CHOIX -------</option>
<option value="11">Poste 11</option>
<option value="12">Poste 12</option>
<option value="13">Poste 13</option>
<option value="14">Poste 14</option>
<option value="15">Poste 15</option>
</select><br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">Date<br>
</td>
<td style="vertical-align: top;"><input type="text" name="jour" size="1" maxlength="2"> / <input type="text" name="mois" size="1" maxlength="2" > / <input type="text" name="annee" size="3" maxlength="4">
</td>
</tr>
<tr>
<td style="vertical-align: top;">Heure<br>
</td>
<td style="vertical-align: top;"><input type="text" name="heures" size="1" maxlength="2"> : <input type="text" name="minutes" size="1" maxlength="2" ><br>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;"><input type="reset" value="Effacer"> <input type="submit" name="envoyer" value="Valider"><br>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<br>
</body>
</html>
Le script bash
#!/bin/bash NUMERO=$1 JOUR=$2 MOIS=$3 ANNEE=$4 HORAIRE=$5 TIMESTAMP=$ANNEE$MOIS$JOUR$HORAIRE FICHIER=$NUMERO$TIMESTAMP.call cd /var/spool/asterisk/tmp/ touch $FICHIER echo "Channel: SIP/$NUMERO" >> /var/spool/asterisk/tmp/$FICHIER echo "Account: $NUMERO" >> /var/spool/asterisk/tmp/$FICHIER echo "CallerID: Reveil <555>" >> /var/spool/asterisk/tmp/$FICHIER echo "MaxRetries: 3" >> /var/spool/asterisk/tmp/$FICHIER echo "RetryTime: 10" >> /var/spool/asterisk/tmp/$FICHIER echo "WaitTime: 10" >> /var/spool/asterisk/tmp/$FICHIER echo "Context: interne" >> /var/spool/asterisk/tmp/$FICHIER echo "Extension: reveil" >> /var/spool/asterisk/tmp/$FICHIER touch -t $TIMESTAMP /var/spool/asterisk/tmp/$FICHIER cp -a /var/spool/asterisk/tmp/$FICHIER /var/spool/asterisk/outgoing && rm /var/spool/asterisk/tmp/$FICHIER
/var/log/apache2/error.log
root@debian:~# cat /var/log/apache2/error.log touch: cannot touch '11201207191835.call': Permission denied /var/lib/asterisk/agi-bin/reveil.agi: line 15: /var/spool/asterisk/tmp/11201207191835.call: Permission denied /var/lib/asterisk/agi-bin/reveil.agi: line 16: /var/spool/asterisk/tmp/11201207191835.call: Permission denied /var/lib/asterisk/agi-bin/reveil.agi: line 17: /var/spool/asterisk/tmp/11201207191835.call: Permission denied /var/lib/asterisk/agi-bin/reveil.agi: line 18: /var/spool/asterisk/tmp/11201207191835.call: Permission denied /var/lib/asterisk/agi-bin/reveil.agi: line 19: /var/spool/asterisk/tmp/11201207191835.call: Permission denied /var/lib/asterisk/agi-bin/reveil.agi: line 20: /var/spool/asterisk/tmp/11201207191835.call: Permission denied /var/lib/asterisk/agi-bin/reveil.agi: line 21: /var/spool/asterisk/tmp/11201207191835.call: Permission denied /var/lib/asterisk/agi-bin/reveil.agi: line 22: /var/spool/asterisk/tmp/11201207191835.call: Permission denied touch: cannot touch '/var/spool/asterisk/tmp/11201207191835.call': Permission denied cp: cannot stat '/var/spool/asterisk/tmp/11201207191835.call': No such file or directory root@debian:~#
C'est tout nikel, mais j'ai un problème de droit .
Comment puis-je faire ?
Merci.
A voir également:
- Passer une variable php a un script bash
- Script vidéo youtube - Guide
- Passer de qwerty a azerty - Guide
- Passer a windows 10 - Accueil - Mise à jour
- Passer de majuscule à minuscule - Guide
- Passer à windows 11 gratuitement - Guide
3 réponses
Bonjour,
Mais ca marche mais j'ai un problème de droit.
Comment puis je faire ?
/var/log/apache2/error.log
Merci.
Mais ca marche mais j'ai un problème de droit.
Comment puis je faire ?
/var/log/apache2/error.log
root@debian:~# cat /var/log/apache2/error.log touch: cannot touch '11201207191835.call': Permission denied /var/lib/asterisk/agi-bin/reveil.agi: line 15: /var/spool/asterisk/tmp/11201207191835.call: Permission denied /var/lib/asterisk/agi-bin/reveil.agi: line 16: /var/spool/asterisk/tmp/11201207191835.call: Permission denied /var/lib/asterisk/agi-bin/reveil.agi: line 17: /var/spool/asterisk/tmp/11201207191835.call: Permission denied /var/lib/asterisk/agi-bin/reveil.agi: line 18: /var/spool/asterisk/tmp/11201207191835.call: Permission denied /var/lib/asterisk/agi-bin/reveil.agi: line 19: /var/spool/asterisk/tmp/11201207191835.call: Permission denied /var/lib/asterisk/agi-bin/reveil.agi: line 20: /var/spool/asterisk/tmp/11201207191835.call: Permission denied /var/lib/asterisk/agi-bin/reveil.agi: line 21: /var/spool/asterisk/tmp/11201207191835.call: Permission denied /var/lib/asterisk/agi-bin/reveil.agi: line 22: /var/spool/asterisk/tmp/11201207191835.call: Permission denied touch: cannot touch '/var/spool/asterisk/tmp/11201207191835.call': Permission denied cp: cannot stat '/var/spool/asterisk/tmp/11201207191835.call': No such file or directory root@debian:~#
Merci.