Csh/tcsh : Check the file existance and run the script

Hi,
I've to wait until a file generated and once its generated, source another script in Linux terminal.

Please help me as this is very very urgent.

The code should be something like

if ( -e "/abc/xyz/a.txt )
   source aaa.csh
else
   sleep

This should be repeated till the if condition is met.

Rgds,
Kumar

That's all you have tried so far?

I think you should show more effort into trying different things.

That's your entire effort at this script (posting code with syntax errors - i.e. unmatched double quotes)?

Dear Neo,
I tried the following piece of code.

#!/bin/csh -f
set ctrl = 1;
while ( $ctrl != 0 )
   if ( -e t ) then
      source aaa.csh
      set ctrl = 0;
   else
      echo "File Not Found : Sleeping"
      sleep 10
   endif
end

I feel its solving my purpose, just wanted to confirm with experts.

OK. thanks for posting.. we have a lot of shell experts here to give you ideas (I'm more of a PHP guy these days)..... be patient and someone will reply to you.

I am not csh programmer. I use ksh or bash for everything. But I'll take a stab at this. The only thing I see with the script is the superfluous but harmless semi-colons on those set statements. But I would code it differently to simplify the script...

#! /bin/csh -f

while ( ! -e somefile )
        echo file not found -- sleeping
        sleep 10
end
source file2
exit 0

and then a test run...

$ ./sleeper
file not found -- sleeping
file not found -- sleeping
file not found -- sleeping
hello
I am file2
$

In another window I typed "touch somefile" to get out of the loop.