+

add smsc option to script mail2gnokii

Benjamin Renard [2012-11-29 16:00:00]
add smsc option to script mail2gnokii
Filename
mail2gnokii
diff --git a/mail2gnokii b/mail2gnokii
index 2273683..e557a42 100755
--- a/mail2gnokii
+++ b/mail2gnokii
@@ -9,7 +9,7 @@
 #   in master.cf :
 #
 #        sms unix    -       n       n       -       1       pipe
-#           flags=Rq user=gnokii:dialout argv=/usr/local/sbin/mail2gnokii ${user}
+#           flags=Rq user=gnokii:dialout argv=/usr/local/sbin/mail2gnokii ${user} [SMSC]
 #
 #   in transport :
 #
@@ -39,8 +39,8 @@ use constant {
 };


-if($#ARGV + 1 != 1){
-	print "Usage : mail2gnokii [phone number]";
+if($#ARGV + 1 != 1 and $#ARGV + 1 != 2){
+	print "Usage : mail2gnokii [phone number] [SMSC phone number]";
 	exit EX_USAGE;
 }

@@ -84,6 +84,15 @@ if (not $mob =~ m/^[0-9]*$/) {
 	exit EX_DATAERR;
 }

+# recuperation du numero du SMSC (si present)
+if (defined $ARGV[1]) {
+	if (not $ARGV[1]=~ m/^[0-9\+]*$/) {
+		print "Invalid SMSC phone number : "+$ARGV[1];
+		exit EX_DATAERR;
+	}
+	$smsc=$ARGV[1];
+}
+
 sub in_array {
 	my ($arr,$search_for) = @_;
 	my %items = map {$_ => 1} @$arr; # create a hash out of the array values
ViewGit