wisely has asked for the wisdom of the Perl Monks concerning the following question:
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?
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?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Automating execution of shell scripts
by BillKSmith (Monsignor) on Aug 30, 2021 at 14:44 UTC | |
by wisely (Initiate) on Sep 02, 2021 at 11:30 UTC | |
by wisely (Initiate) on Sep 03, 2021 at 11:52 UTC | |
by choroba (Cardinal) on Sep 03, 2021 at 13:01 UTC | |
by hippo (Bishop) on Sep 03, 2021 at 13:07 UTC | |
by BillKSmith (Monsignor) on Sep 04, 2021 at 01:42 UTC | |
by wisely (Initiate) on Sep 20, 2021 at 07:51 UTC | |
by AnomalousMonk (Archbishop) on Sep 20, 2021 at 18:33 UTC | |
| |
by BillKSmith (Monsignor) on Sep 20, 2021 at 16:09 UTC | |
Re: Automating execution of shell scripts
by roboticus (Chancellor) on Aug 30, 2021 at 13:42 UTC |
Back to
Seekers of Perl Wisdom