user7169406
user7169406

Reputation: 1

File trigger to watch multiple files in a folder

When wildcards is used with file trigger in autosys to watch multiple files, is there any way or attribute to get the file name which triggered it.

Upvotes: 0

Views: 6338

Answers (1)

badjr
badjr

Reputation: 2296

You can define the file trigger job using a JIL script:

insert_job: file_trigger
job_type: FT
machine: machine_name
owner: user_name
watch_file: /path/to/file/*pattern*
watch_file_type: CREATE

Then define a CMD job to execute a command after success of the file_trigger job:

insert_job: cmd_job
job_type: CMD
command: /path/to/script/script.sh
machine: machine_name
owner: user_name
condition: success(file_trigger)

In script.sh, you can find the files that match the pattern you are looking for:

#!/bin/bash
files=(/path/to/file/*pattern*)
echo "The first matching file was ${files[0]}"

${files[0]} holds the file name of the first file that matches the pattern. The first file that matches the file trigger's wildcard is also the same file that matches the shell script's wildcard.

Upvotes: 1

Related Questions