Executing perl files in many directories.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Executing perl files in many directories.
# 1  
Old 10-20-2015
Executing perl files in many directories.

Good morning!

I need your help again.

I have some perl file. This file, to work, needs to be executed in appropriate directory, e.g. /mnt/disck/new files/abc/003

I need a shell script which:

1) will go to /mnt/disk2/new files/abc/003/perl.pl
2) execute it
3) go to the next directory in new files e.g. ../new files/abd/003/ and execute perl file.
4) do it for all files in new files dir:
Code:
../new files/abc/003/perl.pl
../new files/abd/003/perl.pl
../new files/abe/003/perl.pl
../new files/abf/003/perl.pl
.
.
.
../new files/zzz/003/perl.pl


Could you help me?

Last edited by Don Cragun; 10-21-2015 at 05:40 AM.. Reason: Add CODE and ICODE tags.
# 2  
Old 10-20-2015
Please use code tags as required by forum rules.

That doesn't sound too logical. Are you sure the perl.pl exists in all those directories?

Execute the perl script using its full path, and supply it with the respective directories, e.g. like
Code:
find "/mnt/disck/new files" -type d | while read DIR; do /full/path/to/perl.pl  $DIR; done


Last edited by RudiC; 10-20-2015 at 08:01 AM.. Reason: Added double quotes for dir name with spaces
# 3  
Old 10-20-2015
Quote:
Originally Posted by RudiC
Please use code tags as required by forum rules.

That doesn't sound too logical. Are you sure the perl.pl exists in all those directories?

Execute the perl script using its full path, and supply it with the respective directories, e.g. like
Code:
find /mnt/disck/new files -type d | while read DIR; do /full/path/to/perl.pl  $DIR; done

Hi,

I didn't use any code tags, since there is no code or any data fragment in my post.
Yes, I am sure that this file is in all directories. And I know that it isn't very logical.
# 4  
Old 10-20-2015
Well, try (untested)
Code:
find "/mnt/disck/new files" -name perl.pl | while read FN; do $FN; done

# 5  
Old 10-20-2015
Quote:
Originally Posted by RudiC
Well, try (untested)
Code:
find "/mnt/disck/new files" -name perl.pl | while read FN; do $FN; done

Unfortunatelly it doesn't work. I am getting some errors from perl file. Normally the file works fine.
# 6  
Old 10-20-2015
Then - correct the errors!
# 7  
Old 10-21-2015
As I said, the file works perfectly and there is no need to change it at this point. The command make a mess.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Archiving and moving files into directories, creating directories, etc.

how can i move "dataName".sql.gz into a folder called 'database' and then move "$fileName".tar.gz * .htaccess into a folder called 'www' with the entire gzipped file being "$fileName".tar.gz? Is this doable or overly complex. so mydemo--2015-03-23-1500.tar.gz > database -... (5 Replies)
Discussion started by: wyclef
5 Replies

2. Shell Programming and Scripting

Perl: script to work with files with the same name in different directories

Hi All, I would like to use a Perl (not Bash) script to work with multiple files of the same name in different directories (all in the same parent directory). I tried to create a loop to do so, but it isn't working. My code so far: while (defined(my $file = glob("./*/filename.txt")) or... (1 Reply)
Discussion started by: elgo4
1 Replies

3. Shell Programming and Scripting

How to run perl script on multiple files of two directories?

Hi I have 100 files under file A labled 1.txt 2.txt.....100.txt(made up name) I have 1 files under file B labled name.txt How can i run the same perl script on 100 files and file name.txt I want to run perl script.pl A/1.txt B/name.txt perl script.pl A/2.txt B/name.txt ....... perl... (3 Replies)
Discussion started by: grace_shen
3 Replies

4. Shell Programming and Scripting

Rename the files in all the directories and sub-directories

Hi all, I have more than 12000 files in 46 different directories and each directory has 2 sub-directories named “dat” or “gridded”. Dat sub-directories have files with extension “jpg.dat” and gridded sub-directories have files with extension “.jpg”. I need to... (1 Reply)
Discussion started by: AshwaniSharma09
1 Replies

5. Shell Programming and Scripting

How to list all the files, directories and sub-directories in the current path except one directory?

Can anyone come up with a unix command that lists all the files, directories and sub-directories in the current directory except a folder called log.? Thank you in advance. (7 Replies)
Discussion started by: Manjunath B
7 Replies

6. Shell Programming and Scripting

How to store files/directories in different directories!!

Hi legends, I am writing a script, in that my requirement is, if all the fill types stored in one directory from that we need to separate different different directories based on the file types. for example in a directory(anish). 5 different types files 1- directory 2- .txt files 2- .sh... (1 Reply)
Discussion started by: anishkumarv
1 Replies

7. UNIX for Dummies Questions & Answers

List directories and sub directories recursively excluding files

Hi, Please help me, how to get all the direcotries, its sub directories and its sub directories recursively, need to exclude all the files in the process. I wanted to disply using a unix command all the directories recursively excluding files. I tried 'ls -FR' but that display files as... (3 Replies)
Discussion started by: pointers
3 Replies

8. Shell Programming and Scripting

Run perl script on files in multiple directories

Hi, I want to run a Perl script on multiple files, with same name ("Data.txt") but in different directories (eg : 2010_06_09_A/Data.txt, 2010_06_09_B/Data.txt). I know how to run this perl script on files in the same directory like: for $i in *.txt do perl myscript.pl $i > $i.new... (8 Replies)
Discussion started by: ad23
8 Replies

9. Shell Programming and Scripting

Perl script not executing

Hi All, I have been given a perl script to modify but which is not running completely.And it is not showing any errors also. The script is : #!/usr/local/bin/perl print "Which transaction? "; print "\n"; print "1 - Inquiry"; print "\n"; print "2 - Delete Bank"; print "\n"; print... (8 Replies)
Discussion started by: usha rao
8 Replies
Login or Register to Ask a Question