[Thread Prev][Thread Next][Index]

Re: [ferret_users] Check file exist before saving it



Hi Dan,

| I would like to check file existence before saving it.
|
You can use shell commands for that:

  let ret = {spawn:"[ -e CTL.nc ]; echo $?"}
  if `ret[i=1] eq "0"` then
    ! . . . file exists . . .
  else
    ! . . . file does not exist . . .
  endif

The shell command "[ -e file ]" returns 0 if the file exists
or a different value if it does not.

The command "echo $?" just prints the return value of the
preceding command to the standard output.

The SPAWN expression of Ferret catches the standard output of the
shell command(s).

There may be a Ferret-proper way.

Regards,
Ryo


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement