in reply to Re: Simple File Test
in thread Simple File Test

I've made the change to the code.. Here it is:
foreach (@test_node_list) { if (-e "/usr/adm/best1_default/collect/$_/noInstance") { # It prob +ably is a node with data if (-e "/usr/adm/best1_default/manager/$_") { # It has +a vis files directory push @node_list, $_; if (-e "/usr/adm/best1_default/manager/$_/$vis_year$vis_mo +nth$vis_zero$vis_day*.vis") { print; } } }
This doesn't generate anything. I realize the filename looks odd but when I check them from the cmdline, it works as expected. I'm trying to say, "If this node has a file called X, then do something. Right now, I just have a print statement there. Eventually, I really want to put a system() instead.

Replies are listed 'Best First'.
Re^3: Simple File Test
by Fletch (Bishop) on Jul 11, 2006 at 23:20 UTC
    I realize the filename looks odd but when I check them from the cmdline, it works as expected.

    You need to expand on what you mean by "check them from the cmdline". If you're saying when you run ls /usr/adm/best1_default/manager/foo/20060711*.vis it shows files, then you've missed what was being said about needing to use glob. Your shell will expand the wildcard *, the -e operator (among other things) will not. If you want wildcard expansion you need to use glob, or do something like using opendir and then grep'ing the results from a readdir.

Re^3: Simple File Test
by kwaping (Priest) on Jul 11, 2006 at 23:20 UTC
    You've misunderstood. Here's the actual code with our suggested edits:
    foreach (@test_node_list) { if (-e "/usr/adm/best1_default/collect/$_/noInstance") { # It prob +ably is a node with data if (-e "/usr/adm/best1_default/manager/$_") { # It has +a vis files directory push @node_list, $_; print "/usr/adm/best1_default/manager/$_/$vis_year$vis_mon +th$vis_zero$vis_day*.vis"; if (-e "/usr/adm/best1_default/manager/$_/$vis_year$vis_mo +nth$vis_zero$vis_day*.vis") { system("/appl/perform/best1home/perl/clean_graphics.pl +", "$_"); print "It exists.\n"; } } } }

    ---
    It's all fine and dandy until someone has to look at the code.