Hello
trap all errors run your program in cron as
/usr/local/bin/contrologo.pl >> /tmp/mylog 2>&1
Larry Lefthook wrote:
> Hi! I have modified gsmcontrol.pl (yty.net) as contrologo.pl. & I wonder
> why my script is not run by crontab when it works when I run it by hand.
> I have a file for the script in /var/gsm/in and when I run contrologo.pl
> from commandline it sends sms message (logo) using external program
> (gnokii) & moves it to /var/gsm/in.handled. But when the script is run
> by cron (all one line):
> 2,7,13,17,22,27,32,37,42,47,52,57 * * * * /usr/local/bin/contrologo.pl
> 2>/dev/null
> it only moves it to the /var/gsm/in.handled, but does not use gnokii for
> sending. Do the contrologo.pl exit & stop after tried once external
> program or can it somehow reply to all messages in if there is? What I
> need to add?
>
> #!/usr/bin/perl -w
>
> # program reads messages from "sms-inbox"-folder and handles them when
> # necessary
> #use strict;
> my $inbox = "/var/gsm/in";
> my $handled = "/var/gsm/in.handled/";
> my $file="";
> my $sendsms = "/usr/local/bin/sendsms.pl";
> my $gnokii = "/usr/local/bin/gnokii";
> my $remove=0;
>
> #for $file (glob "$inbox/*.txt" ) {
> for $file ( <$inbox/*.txt> ) {
> my $sender="";
> my $remove=0;
> open FILE, $file or die "Cannot open file ($file): $!";
> while (<FILE>) {
> if (/Sender:/) {
> s/.*Sender:/Sender:/;
> ($tmp,$sender,@tmp) = split (" ",$_);
> chomp($sender);
> $sender =~ s/\+//g;
> $sender =~ s/ //g;
> }
>
> if (/^GET/) { # ohjausdataa ...
> &getlogo($sender,$_);
> $remove=1;
> }
> }
> close FILE;
> if ($remove == 1) {
> `mv $file $handled`;
> #if ( $remove ) {
> #system( 'mv', $file, $handled ) == 0 or warn "Cannot move
> # $file: $?";
> }
> }
>
> sub getlogo {
> # sauna($sender, $line);
> my $sender = $_[0];
> my $line = $_[1];
>
> if ($line =~ /KUKAT/) {
> my $logo = "/var/gsm/logos/kukat.nol";
> $sender =~ s/358/0/;
> #exec "gnokii --sendlogo op $sender $logo 244-05";
> # Tutki which Operator
> if ($sender =~ /^050/) {
> system "gnokii --sendlogo op $sender $logo 244-05";
>
> }
> elsif ($sender =~ /^040/) {
> system "gnokii --sendlogo op $sender $logo 244-91";
> }
> }
> }
>
>
>
>
> _________________________________________________________________
> Join the world�s largest e-mail service with MSN Hotmail.
> http://www.hotmail.com
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]