--- SilverFox <[EMAIL PROTECTED]> wrote: > Jeff Westman wrote: > > > > > --- SilverFox <[EMAIL PROTECTED]> wrote: > >> Hey can someone help me figure out why the value of $file_exists won't > >> change even when the file is mssing???? Thx. > >> > >> #!/usr/bin/perl -w > >> $out="/home/laptop/scripts/perl/logs/resetmf.log"; > >> open OUT, ">>$out" or die "Unable to open $out :$!"; > >> > >> @site=("Machine1","Machine2"); > >> #telnet > >> use Net::Telnet; > >> $t = new Net::Telnet (Timeout=>10, > >> Errmode=>'die', > >> Prompt=>'/\$ $/i'); > >> foreach (@site) { > >> $t->open($_); > >> $t->login('username','passwd'); > >> print OUT scalar(localtime), " Conn EST: $_.\n"; > >> > >> > >> $dir="pf/working/output/Channel_status"; > >> @newdir=("/Machine1/$dir","/Machine2/$dir","/Machine9/$dir"); > >> > >> for($x=0; $x <= $#newdir; $x++) { > >> > >> > >> $file_exists = $t->cmd ("perl -e 'print 1 if (-s \"$newdir[$x]\")'") or > >> warn "Unable to execute: $!\n"; > >> > >> if ($file_exists) { > >> print "Found it\n"; > >> }else{ > >> print "File Missing\n"; > >> > >> } > >> } > >> } > >> > > > > When I tried to run your cmd/perl line simply to test that part, I got: > > > > $file_exists = $t->cmd ("ksh: syntax error: `(' unexpected > > > > Alternatively, you might try something simpler like: > > > > $file_exists = $t->cmd("test -f $newdir[$x] && print 1 || print 0"); > > > > > > > > -JW > > > > > hmmm....I'm still getting the same results. Think it have something to do > with my shell (/usr/bin/sh).
First, see if you can even do that shell test actually logged into that box, see what it returns. Second, I've had problems with telnet.pm -- kind of flakey at times, so you might try this instead: $file_exists = sprintf("%s", $t->cmd("test -f $newdir[$x] && print 1 || print 0") ); That did the trick for me when I didn't get teh right results back. JW __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]