apollo has asked for the wisdom of the Perl Monks concerning the following question:
I've been at this for two days now and I can't get it to work. Scripting and perl are brand new to me, so I'm sure there are at least a few nuances I'm missing. Anyways, I need the script to do three things:
1. make a list of all (and only) directories within the current directory
2. cd into each directory in the list
3. run foo.exe in each directory and return to the main directory
The main directory includes files in addition to the target directories.
#!/usr/bin/perl -w @file=`find * -type d`; foreach (@file) { `cd $_;/somepath/foo`; }
It's been suggested that I use the following in place of find * -type d
$foo=`ls -d *`; @file = split'',$foo;
Let me know if I'm missing any crucial info here, this is my first post in the monastery!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: trouble with a simple script
by toolic (Bishop) on Jul 07, 2010 at 18:52 UTC | |
by ikegami (Patriarch) on Jul 07, 2010 at 19:14 UTC | |
|
Re: trouble with a simple script
by zek152 (Pilgrim) on Jul 07, 2010 at 18:57 UTC | |
by ikegami (Patriarch) on Jul 07, 2010 at 19:16 UTC | |
|
Re: trouble with a simple script
by apollo (Initiate) on Jul 07, 2010 at 19:26 UTC | |
by ikegami (Patriarch) on Jul 07, 2010 at 19:31 UTC | |
by ikegami (Patriarch) on Jul 07, 2010 at 19:46 UTC | |
|
Re: problem running executable in subdirectories
by apollo (Initiate) on Jul 07, 2010 at 19:54 UTC | |
by ikegami (Patriarch) on Jul 07, 2010 at 20:34 UTC |