LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-27-2012, 04:32 AM   #1
bal_nair1
Member
 
Registered: Apr 2012
Location: Bangalore,India
Posts: 41

Rep: Reputation: Disabled
Smile notification as popups when a file being written


I would like to know

Is it possible to get a notification as pop-up in linux

when a folder with extension '.aqs' written

a popup should come

as " The folder has been written "


Thank you in advance
 
Old 07-27-2012, 05:14 AM   #2
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
I not fully understand, but if you want to show a popup window when somewhere a folder with .aqs extension has been written, then you can use "inotify" mechanism to react on filesystem change and "xmessage" to display message.
 
Old 07-27-2012, 05:49 AM   #3
bal_nair1
Member
 
Registered: Apr 2012
Location: Bangalore,India
Posts: 41

Original Poster
Rep: Reputation: Disabled
Smile

thats fine....wht could be done if inotify is not present in the system
 
Old 07-27-2012, 07:07 AM   #4
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
You want to inspect a specific directory or whole partition?
 
Old 07-29-2012, 01:47 AM   #5
bal_nair1
Member
 
Registered: Apr 2012
Location: Bangalore,India
Posts: 41

Original Poster
Rep: Reputation: Disabled
I will expalain

what happens is I used to submit jobs in server and run job wud be written in the directory

/home/balnair/transfer/

as a set of files in the folder 'scs.aqs'

So I would like to get the notification such as
" Your job has been run " once it is finished

Once the job is run,

Files will be located as shown below

/home/balnair/transfer/scs.aqs

abc.op2
cvf.f06
bgy.f04
asa.test...



Hope you get my requirement
 
Old 07-30-2012, 03:35 AM   #6
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
Better option would be to process who write these files will signal somehow that it finishes. For example it can output to known file text for example 1 when it begin, 2 when it end. If you have no control of this process, and really you can only react on created file in specified directory, then you can use something like that:
Code:
#!/bin/bash

while [[ $(ls /home/balnair/transfer/scs.aqs | grep -c '.*') == 0 ]]
do
    sleep 5
done
xmessage 'Your job has been run.'
But, because you don't known how many files will be created you will be notified when first file will be, so I think this will be useless if these files are created slowly.
 
Old 07-30-2012, 04:01 AM   #7
bal_nair1
Member
 
Registered: Apr 2012
Location: Bangalore,India
Posts: 41

Original Poster
Rep: Reputation: Disabled
how would we make this script always running on background?..that is whenever a folder is created with .aqs extension I should get the notification
 
Old 07-30-2012, 04:33 AM   #8
bal_nair1
Member
 
Registered: Apr 2012
Location: Bangalore,India
Posts: 41

Original Poster
Rep: Reputation: Disabled
HOW WOULD WE MAKE THIS SCRIPT RUNNING IN BACKGROUND ALWAYS.........SO THAT WHENEVER A FOLDER WITH EXTENSION .aqs IS WRITTEN

MESSAGE SHOULD COME
 
Old 07-30-2012, 04:39 AM   #9
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
You can enclose it to forever loop:
Code:
#!/bin/bash

while true
do
  while [[ $(ls /home/balnair/transfer/scs.aqs | grep -c '.*') == 0 ]]
  do
    sleep 5
  done
  xmessage 'Your job has been run.'
done
And run it in from your X session autostart place with ampersand character "&" on the end. This script react on created file in this directory. If you want to react on any directory with .aqs extension then change while line with this:
Code:
while [[ $(ls -d /home/balnair/transfer/*.aqs | grep -c '.*') == 0 ]]
 
Old 07-30-2012, 04:45 AM   #10
bal_nair1
Member
 
Registered: Apr 2012
Location: Bangalore,India
Posts: 41

Original Poster
Rep: Reputation: Disabled
srry sir...m new to linux.....Could you please let me know how to open X session auto start place
 
Old 07-30-2012, 06:03 AM   #11
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
Which distribution are you using?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Tracing how a file is actually written. zishan.shaikh Linux - Kernel 2 01-05-2012 10:25 PM
How would I see how many times a file has been written to? anon02 Linux - Software 6 09-23-2011 01:34 AM
moving a file while is being written omnio Programming 10 03-23-2007 09:25 AM
cannot open file to written venki Linux - Newbie 5 12-18-2006 06:57 AM
How to get last file written to directory kd5giv Linux - Networking 4 03-29-2004 02:26 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration