Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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):
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

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2023-01-29 15:50 GMT
Find Nodes?
    Voting Booth?

    No recent polls found