0

I'm very new to programming. Give me some idea or where and how to start with the below requirement. It's in shell script.

I need a shell script that checks whether the particular path has a .tag file if yes, it has to internally trigger a control M job which sends the file to destination location.If no, just exit with a error message. This has to be done in the script. say

filepath="/home/ss/proj/" filename=abc.tag

The file is generated in the path by Control M. So in that particular job I need to call this script which triggers a new control M job which sends the file.

newbie
  • 1

2 Answers2

0

This is to be done as "Control M calling your script" and not as "your shell script calling Control M".

You need to create shell script first, as simple as :

not_found=1
for i in `ls $filepath/*\.tag` ; do
   echo "file $i present"
   mv $i $dest_dir
   not_found=0
done 

exit $not_found  # if $not_found is 0, exit 0 will be success.

Then ask whoever gave the job, how to add this to Ctl-M scheduler in their environment, so after this job runs and exits it will trigger the other CM job you are talking about.

Jay Kumar R
  • 537
  • 2
  • 7
  • Thanks for the response. However, I don't want to move the same .tag file to the destination folder. I need to check if the .tag file is present in the particular path, if so trigger a CM job which will send the .xml file which is in the different location followed by the .tag file. – newbie Feb 20 '16 at 21:20
  • you cannot trigger a CM job. I repeat, CM should trigger the job based on success or failure of this shell script. This script does the job well with exit status. – Jay Kumar R Feb 20 '16 at 23:13
0

Jay is correct - ask your Control-M guy to add an action (final tab in the job def) and specify an On/Do with an "Order Job" based on the return code from the original script.

Mark
  • 316
  • 1
  • 5