Hi all, This is my first post here and my question is not so much about the exact code implementation at this stage but rather what is the best way to achieve this and is it possible.
So I have these two shell scripts that I need to run to create environments for my work and I can't make any changes to the shell scripts themselves.
So the first shell script takes in files as well as a few arguments and created a directory based on them and it also prints in the terminal the path to the created dir.
So for example my first script will look like this: ~/shell_1.csh file1 arg1 arg2
And the output from it will be a directory like this (number after the underscore is the date):
/project/file1/file1_270821.
I created a perl script to automate the execution of the above shell script I just give it all the files I need and it extracts the needed argument and runs the shell script for each one.
The second shell script I need to execute in each of the created directories.
So for the above example I would change my dir to /project/file1/file1_270821 and then execute shell_2.csh in it.
This is tedious if I have just created 5 such directories for example, so I want to automate this.
What i was thinking is to have it check the directories for all files I have passed to it and run the second shell script in the one with the latest date.
So for example if I have passed file1, my perl script to go into the /project/file1 dir, find the file1_* with the latest date and then run the shell_2.csh in that dir.
Is it possible for this to be achieved with perl? If yes is the way with checking dates the most efficient way?

In reply to Automating execution of shell scripts by wisely

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.