This is about how to Monitoring folder for new files using shell script
im doing a project using smsserver tools 3. i have used a perl script
to handle incoming messages. the content of each message must be
directed to a java program. this program generates the answer to reply
to the user .so i need to call the java program from the perl code.
this is my perl code
Code:
//******************************************************************************************************************************************
#!/usr/bin/perl -w
use strict;
use File::Monitor;
use File::Monitor::Object;
my $number = '';
my $msgFrom = '';
my $outgoing = "/home/T/Documents/run/outgoing/";
my $extract ="/home/T/Documents/run/extract part/";
my $temp = '/var/spool/sms/incoming';
my $monitor = File::Monitor->new();
my $newline = 0;
$monitor->watch( {
name => "$temp",
recurse => 1,
callback => \&Test,
} );
$monitor->scan;
for (my $i=0; $i < 100; $i++)
{
my @changes = $monitor->scan;
sleep 5;
}
sub Test
{
my ($name, $event, $change) = @_;
my @adds = $change->files_created;
my @dels = $change->files_deleted;
if(@adds){
print "Added: ".join("\nAdded: ", $adds[0])."\n"; # if @adds;
my $filename = $adds[0];
open (INFILE, $filename); # if @adds;
while (my $line = <INFILE>) {
chomp $line;
$line = lc($line);
if ($newline == 1) {
$msgFrom = $msgFrom.$line;
printf "*************".$msgFrom;
}
if ($line =~ /^from: (.*)/) {
$number = $1;
} elsif (length($line) == 0) {
$newline = 1;
}
}
close INFILE;
open(OUTFILE1 , ">".$number.".txt");
print OUTFILE1 ("hi gfdg");
close OUTFILE1;
open(OUTFILE, ">".$outgoing."sms".$number."-".int(rand(100000)));
#open for write, overwrite
print OUTFILE ("To: ",$number); #write text without newline
print OUTFILE "\n\n";
print OUTFILE join(',','hi is this working '); #write text
print OUTFILE "\n"; #write newline
close OUTFILE;
}
}
//******************************************************************************************************************************************
can anyone help me to write this perl code in shell script ?
or is there a way to call java programe inside perl code?
Last edited by pludi; 04-29-2010 at 10:06 AM..
Reason: code tags, please..
perl script:
my $logdir = '/smp/dyn/logfiles/fsm/mp/mp';
$logdir = $logdir ."/mp${toDate}*";
i tried to make it..as below .. but not working ..
date +%m%d%y
logdir = /smp/dyn/logfiles/fsm/mp/mp
logdir=$logdir/mp"$date"
but it was not working.....
can someone please help me out in... (1 Reply)
Hi,
I have a sheel script that invokes a perl script...Now, instead havin the perl script as a separate file I'd like put the contents in the sheel script itself...But I am not sure how ro run that perl script contents.please help me
Thanks (1 Reply)
Hi all experts,
I am new to Unix. Could you please help me to convert the following PERL script to SHELL? I will appreciate.
#!/bin/sh
use strict;
use warnings;
my $robot_num = 0;
my %rob_tapes;
foreach (`/usr/openv/volmgr/bin/vmquery -l -rn $robot_num`)
{ $rob_tapes{(split)} = 1; }... (6 Replies)
I need a shell script which will convert the given string within a <title> tag to Capitalize case.
E.g "<title>hi man: check this out</title>"
to "<title>Hi Man: Check This Out</title>" (11 Replies)
Hi all,
Not sure if this should be in the programming forum, but I believe it will get more response under the Shell Programming and Scripting FORUM.
Am trying to write a customized df script in Perl and need some help with regards to using arrays and file handlers.
At the moment am... (3 Replies)
Hello,,I have a very small script that contains these lines; and it works perfectly; however I need to use Perl now as I will need to feel variables from a MySQL table into this; to it would be nice to start by converting this first...
find / -perm 777 \( -type f -o -type d \) -exec ls -lid {}... (1 Reply)
hi,
i want to pop up an alert box using perl script. my requirement is.
i am using a html page which calls a perl script. this perl script calls a shell script.. after the shell script ends its execution, i am using exit 0 to terminate the shell script successfully and exit 1 to terminate the... (3 Replies)
We are using AIX version 7100-03-05-1524
Please provide shell script version (bash or ksh) of below perl code,since we need to have line breaks in huge XML files
#!/usr/bin/perl
#
# Purpose: Read an XML file and indent it for ease of reading
# Author: RedGrittyBrick 2011.
# Licence:... (11 Replies)
Discussion started by: vishwanath001
11 Replies
LEARN ABOUT OSF1
uudemon.cleanu
uudemon(4) Kernel Interfaces Manual uudemon(4)NAME
uudemon.admin, uudemon.cleanu, uudemon.hour, uudemon.poll - Administrative shell scripts for polling remote systems, cleaning up spool
directories, reporting status to the system administrator, and routine invocations of the uuxqt and uusched daemons
SYNOPSIS
These shell scripts reside in the following directory:
/usr/lib/uucp
DESCRIPTION
All the scripts can be run from the command line or can be run automatically by the cron daemon. To automatically run the scripts, remove
the comment character (#) from the beginning of the relevant line in the /var/spool/cron/crontabs/uucp file.
This script reports status to the system administrator. It issues the uustat command to find out the status of uucp jobs. It mails the
results to the uucp login ID. The script may be modified to send mail to any login ID such as the uucp administrative login ID (uucpa) or
root. This script cleans up the /var/spool/uucp and /var/spool/uucppublic directories by running the uucleanup command. The uucleanup com-
mand is run with the following parameters: -C7, -D7, X2, -o2, -W1. This script runs the uusched and uuxqt daemons in the background. This
script polls the systems listed in the /usr/lib/uucp/Poll file. The uudemon.poll script should be scheduled before the uudemon.hour
script. This allows uudemon.poll to create any command files before cron runs the uudemon.hour script.
FILES
Contains the uudemon.admin, uudemon.cleanu, uudemon.hour and uudemon.poll files. Contains the uucp file.
RELATED INFORMATION
Commands: cron(8), uucleanup(8), uusched(8), uuxqt(1)
Files: /usr/lib/uucp delim off
uudemon(4)