I posted this question earlier but I have now used the feedback and simplified the php program to show how it still fails. using the file_exists with an array always fails: Here is a simple program I wrote that shows the failure:
[root@dsmpp1 steve]# ls -l data
total 4 -rw-r--r-- 1 root root 0 Sep 19 11:41 test_file
[root@dsmpp1 steve]# cat test_file.php
`#!/usr/bin/php -q
<?php
$i=1;
$testarray=array();
$testarray[$i]="test_file";
echo "testarray $testarray[$i]\n";
**if(file_exists("/home/steve/data/testarray[$i]")) {**
echo "file exists\n"; }
else { echo "file does not exist\n"; } `
[root@dsmpp1 steve]# php -q test_file.php
testarray test_file
file does not exist
[root@dsmpp1 steve]#
I used the double quotes around the directory and file name as suggested earlier and it is still not working.
grep 127.0.0.1 /etc/hosts |awk '{print $3}'; #$hostname[$i]="localhost"; echo "hostname[$i] = $hostname[$i]\n"; if(file_exists("/home/steve/data/$hostname[$i]")) { echo "do nothing appserver file exists\n"; } else { echo "No file exists create one\n"; $touch=touch /home/steve/data/$hostname[$i]; } ?>