Polling file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Polling file
# 1  
Old 03-10-2017
Polling file

HI
I need some help on this below one
Have summuary file coming on daily basis with list of file names and count ,if the summuary file not exist ,pool it for every 5 mins till it arrives .Once arrived remove first and last line from the file and check all the files in respective director all are exist it,If it exists compare count with file against file exist in OS ,if it matches for all the files then move it some other server .Can any help from any one ?

Regards,
MM

---------- Post updated at 01:44 AM ---------- Previous update was at 01:18 AM ----------

Take all the files from this test file and check whether all are exist ,if all are exist then move to some other direcotry

Example
summary.txt



Code:
 PASSIVELBS_xxx_ 1 
 PASSIVELBS_xxx_ 2 
 PASSIVELBS_xxx_ 3


Last edited by rbatte1; 03-14-2017 at 09:27 AM.. Reason: CODE tags again
# 2  
Old 03-10-2017
Hi, what have you tried so far and where are you stuck?
# 3  
Old 03-11-2017
Hi
want to check ,grep and sed cannot use single like ,i want to find **** lines in file,if exist only remove those lines .When i am doing the below check throwing error

Code:
CHECK_FILE=`egrep -i '******' ${BASE_PATH}/${FILENAME}|sed -i '1d;$d'`


sed: no input files

Last edited by jim mcnamara; 03-11-2017 at 10:38 AM..
# 4  
Old 03-11-2017
Code:
if [ -f  ${BASE_PATH}/${FILENAME} ] ; then
    awk ' index($1, "*")==1 {next} 
            {print} ' ${BASE_PATH}/${FILENAME}  > tmp.tmp
    mv tmp.tmp ${BASE_PATH}/${FILENAME}
fi

This deletes the lines you want deleted. Drop the mv command if you want to keep the file as it was. Your original code does not make sense to me. The CHECK_FILE variable will always be "empty".
# 5  
Old 03-11-2017
Thanks jim,its working perfect.I need one more conditions to check
Let say summary.txt having 3 files but when checking only 2 files are available in that location ,ensure that 3 files should be exist before proceeding to another step .

Code:
summary.txt
========
PASSIVELBS_xxx_ 1 
PASSIVELBS_xxx_ 2
PASSIVELBS_xxx_ 3

# 6  
Old 03-11-2017
PLEASE DON'T edit posts after people have replied to it, pulling the rug from under their feet (and here: yours as well) and rendering their efforts useless!

With your modifications of post#1, jim mcnamara's proposal becomes a pointless no-op.
And, BTW, grepping for a pattern like '****' as you do in post#3 won't work as expected because * is a regex multiplier (zero or more times) character. To remove starred and blank lines from your input, try
Code:
grep -v '\*\|^ \+$' file

The error in post#3 is due to you wanting sed to "edit-in-place" stdin from a pipe.

Re your new request: do you just want a file count of three, or should exactly those three listed files exist? If the former: are there always exactly two header lines to be skipped?

Last edited by RudiC; 03-11-2017 at 01:12 PM..
These 3 Users Gave Thanks to RudiC For This Post:
# 7  
Old 03-11-2017
Hi ,
Below code is working fine,exit from loop if not matching .I need to be loop forever untill match both files count .Any help would be appereciated

Code:
summary=`cat ${BASE_PATH}/${FILENAME|wc -l`
check=`ls -l PASSIVELBS_xxx_*|wc -l`
while [ $summary != $check ];do 
echo "Summary files are $summary"
echo "Checksum files are $check"
echo "Files are not matching with checksum"
exit 1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Polling target on Serviceguard

Hi Guys, we are planning to enable polling target on our SG in reference to this link MC/ServiceGuard: Subnet Goes Down when one of the Cluster Node is Down - HP Customer Care (United States - English) since our server is already in production can we apply the changes with ex. "cmapplyconf... (1 Reply)
Discussion started by: batas
1 Replies

2. Shell Programming and Scripting

Polling for existence of file on remote host

I am polling a file on remote host. I have this code that works, but can't explain why it works. while user@remote.no-exist.com 'ls /user/app1/.done'` ] do echo Sleeping for 5 secs sleep 5; done This code works in the way that when the .done file exists on the remote host, the script... (1 Reply)
Discussion started by: starlatch
1 Replies

3. Programming

Db polling...

Hi! Im trying to make a program that polls a mysqlDB every 5 minutes. the poll checks a scheduletable in the dB and exicutes a function if there was a "go" in the scheduletable, and if it retrives a "no go" from the table it should just wait for another 5 minutes before re polling the DB, ... (1 Reply)
Discussion started by: karlblau
1 Replies

4. Solaris

NTP polling interval

Is it possible to change the ntp poll manually. I notice that ntp poll is changing autimatically. (1 Reply)
Discussion started by: ningy
1 Replies

5. Shell Programming and Scripting

Unix Polling agent

I plan to run a script which will run in background and at predefined times send mails to user . I dont have acees to autosys/ Cron / at jobs My loop works like this while (true) do getx_time=`date +%H%M` if ; then script1.sh mail_sent_flag=1 elif ; then script2.sh... (1 Reply)
Discussion started by: ultimatix
1 Replies

6. Shell Programming and Scripting

Polling continously for presence of a file

Hi, My os is sun solaris 5.10 and Korn shell scripting. I have a file name like CCNA_EARLY_SWP.w062309 where 062309 is date in mmddyy .This is the value date of the file.(will I need to check continously from 5.00 - 7.00 am daily for this file . If the file has not come at 5 am or 7am... (4 Replies)
Discussion started by: manoj39
4 Replies

7. UNIX for Advanced & Expert Users

How to avoid polling???

Hi all, I have a directory where some process is keeping incremental/new log files. I need to code a program which will periodically poll this directory and if it founds a new file arrived then copy that new file to some other specific directory. We are OK with this polling approach. I just... (3 Replies)
Discussion started by: zing_foru
3 Replies

8. UNIX for Advanced & Expert Users

Polling an FTP site for a file

Hi, I'm after a bit of advice for the best way to collect files from an ftp server via a unix process. The main issue here is the frequency, the job needs to check for files every minute or so between 8am and 8pm and pull them down to the box if there is anything there. Originally the... (6 Replies)
Discussion started by: Peejay
6 Replies

9. Programming

How to implement polling for a function using timer in C?

Hi, Can you please help me in implementing a timer based polling for function in C? ie. the function should be called in say 30secs(when 30secs has lapsed). Thanks (7 Replies)
Discussion started by: naan
7 Replies

10. Programming

Help - Polling Script

How do I write a shell script to perform polling just like what happens with Microsoft mail. i.e display an alert box. (1 Reply)
Discussion started by: brianmu
1 Replies
Login or Register to Ask a Question