Automatic script trigger


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Automatic script trigger
# 1  
Old 06-07-2014
Linux Automatic script trigger

Hi,

I'm looking for a way to solve the following scenario:

A shell should automatically trigger / run when a text file is placed or present at a specific location.

My idea - to create a cron / anacron for every minute and inside that i will call a temp script. Temp script will move to my required path and using a for loop i will check for files in that directory and execute my script.

Eg:
Code:
cd /a/b/c
for i in *
{
  sh core_script.sh $i
}

Is this correct? and is there any other ways i can achieve this.

share your suggestions.

Last edited by Gautham; 06-07-2014 at 03:28 PM.. Reason: modified code
# 2  
Old 06-07-2014
If you are on a Linux based platform, use inotify. It can be set up to work exactly as you describe - wait for a new file to appear then exit, used inside a loop.
# 3  
Old 06-07-2014
Thanks Jim.

In case of unix is there any feature for this.
# 4  
Old 06-07-2014
Quote:
Originally Posted by Gautham
Thanks Jim.

In case of unix is there any feature for this.
You're giving us confusing and inadequate information to really help you.

You posted a message to the Linux and UNIX Forums asking how to do something to files in directory \a\b\c, but that is a Windows style path; not a UNIX and Linux stye path.

You were given a suggestion that might work on Linux systems; and then you tell us you want a solution for UNIX systems. What you're asking for is not something that is covered by the standards (so if there is a way to do it, it may vary considerably from platform to platform).

What UNIX system are you using? Which release of that UNIX system are you using?

If you're using a recent Solaris or Mac OS X system, you might be able to use dtrace (although doing so may require extended privileges). (See the dtrace(1M) man page or the Oracle Solaris Dynamic Tracing Guide for details.)

If you're using some other UNIX system, it might also have dtrace or some other facility that will allow you to monitor changes to a directory in general, creation of files in a directory, or even creation of files whose name ends with .txt in a specific directory.

Giving details about your environment when asking a question makes it much more likely that you will get answers that work for you.
# 5  
Old 06-07-2014
I'm sorry Don, as i'm new here not aware of other platforms.

It is Solaris 5.10 version.

In destination path we won't create any .txt files .. it would be an incoming file to that path and which will trigger a script

Last edited by Gautham; 06-07-2014 at 03:30 PM.. Reason: additional info
# 6  
Old 06-07-2014
Quote:
Originally Posted by Gautham
I'm sorry Don, as i'm new here not aware of other platforms.

It is Solaris 5.10 version.

In destination path we won't create any .txt files .. it would be an incoming file to that path and which will trigger a script
Huh? How does "an incoming file" get to that path if a file isn't created with that path? You can use dtrace to track link() and symlink() as well as open() with O_CREAT set (AKA creat()) if you mean that the file is created or copied elsewhere and linked into this directory when it is complete.
This User Gave Thanks to Don Cragun For This Post:
# 7  
Old 06-12-2014
Quote:
Originally Posted by Don Cragun
Huh? How does "an incoming file" get to that path if a file isn't created with that path? You can use dtrace to track link() and symlink() as well as open() with O_CREAT set (AKA creat()) if you mean that the file is created or copied elsewhere and linked into this directory when it is complete.
Incoming File - like why can't it be moved or copied from some other path.

So only when i CREATE a file in that specific path i would be able to use dtrace.

Any way to accomplish if the scenario is in this manner?.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Trigger script based on condition

Hi Guys, I am having below code which runs based on condition, Is it possible to check condition at the time of trigger code=$1 if ;then nohup sh script.sh $val 1 & fi I need to trigger if the $code = JP then only to trigger nohup sh script.sh $val 1 & My try but wanted... (4 Replies)
Discussion started by: Master_Mind
4 Replies

2. Shell Programming and Scripting

To trigger script on particular instance

Hi Guys, I have a main_script.sh which runs every day and scheduled in crontab. in the main script i read data from config file test.config apple mango orange main_script.sh for i in `cat test.config` do if then echo 'Apple' (3 Replies)
Discussion started by: Master_Mind
3 Replies

3. Shell Programming and Scripting

Shell script trigger using http interface

Hi I have created a shell program, which takes a series of parameters as shown in the below code. Its working good from terminal. My program restorejob.sh -g <NAME> -p <Path-to-search> -r <Path-to-restore> Its working fine from bash shell. I want to extend this functionality like... (1 Reply)
Discussion started by: rakeshkumar
1 Replies

4. Shell Programming and Scripting

Execute shell script from plsql trigger

Hi, I have been assigned a job which requires me to send mails from unix(Mailx) upon on certain actions triggered in the database. On insert/update of a certain field into one of the database tables the shell script present in Unix box responsible to send mail though mailx needs to be triggered... (7 Replies)
Discussion started by: hemant.bs11
7 Replies

5. Shell Programming and Scripting

Trigger a script by consequtive scripts in crontab

Hello Friends, I've been searching solutions for an exceptional backup case recently, I need someone to guide me, suggest a method pls. In a production system we have backup scripts, they are run by cron one after another, and monthly. There is 1 hour difference between each consecutive script... (1 Reply)
Discussion started by: EAGL€
1 Replies

6. Shell Programming and Scripting

How to trigger a script based on another log file.

I need to execute my script as soon as one log file arrives. This log file is named as logyymmdd. I need to add trigger to my script based on this logfile. Please guide. (1 Reply)
Discussion started by: nishigupta
1 Replies

7. UNIX for Dummies Questions & Answers

Can we trigger an shell script on an event

Hi, My program A updates a log called logA. I have a shell script S that is responsible to send emails reading from the log. I want to trigger execution of the script whenever there is an update to the log. Thanks in advance. (8 Replies)
Discussion started by: cv_pan
8 Replies

8. Shell Programming and Scripting

Trigger Shell Script from Current Script

Hello all, I'm new to shell programming and need some help. I would like to set up a step within a shell script to trigger another shell script to run, based on the highest return code generated in the current script. For example, if the highes return code value in the current script is less... (1 Reply)
Discussion started by: mmignot
1 Replies

9. Shell Programming and Scripting

Check if trigger Script is running

HI, I have a script which will be running all the time...it is like a trigger.. wakesup every 10 minutes(trigger.sh) executes, and I want to write another script which monitors this script every one hour and if it finds that trigger script is not running it should start it and exit...and here... (9 Replies)
Discussion started by: mgirinath
9 Replies

10. Shell Programming and Scripting

Shell script call from a DB trigger

Has anybody been able to execute a shell script call from a database trigger? If so what are the steps to execute it? Do we have any specific packages in Oracle? Reards, Rahul. (1 Reply)
Discussion started by: rahulrathod
1 Replies
Login or Register to Ask a Question