This code achieves the same functionality without creating an exception:

var fd = new File("/tmp/blah");

if (fd.exists) {

  console_log((fd.name) + "exists\n");

} else {

  console_log((fd.name) + "does not exist\n");

}

 

However, the question remains: why did this pclose error crop up recently?

-Jason

 

From: Jason Moran
Sent: Friday, June 08, 2012 4:16 PM
To: freeswitch-users@lists.freeswitch.org
Subject: [Freeswitch-users] JS File Operation Error with latest FS

 

A spidermonkey File operation (often) causes the output of “ASS #####” followed by a “File operation pclose failed” error now that I’ve done a make current (last  update was 4 weeks ago).   The code puts a 0 or 1 into the variable fdFoundFile for later testing. This has worked for months until the make current.  Now it fails with the pclose error 4/5 times.

 

CODE:

    console_log("info","-3-\n");

//Do a check to make sure we can read the file

var fd = new File("|[ -f "+myFileName+" ] && echo 1 || echo 0");

    console_log("info","-4-\n");

fd.open("read");

    console_log("info","-5-\n");

var fdFoundFile = fd.read(1);

    console_log("info","-6-\n");

fd.close();

    console_log("info","-7-\n");

 

LOG:

2012-06-08 15:52:14.717917 [INFO] Testcall.js:1 -3-

2012-06-08 15:52:14.717917 [INFO] Testcall.js:1 -4-

2012-06-08 15:52:14.717917 [INFO] Testcall.js:1 -5-

ASS 30937

2012-06-08 15:52:14.717917 [INFO] Testcall.js:1 -6-

2012-06-08 15:52:14.717917 [ERR] Testcall.js:258  Error: File operation pclose failed

 

The # following “ASS” always changes and keeps on increasing.

 

Thanks,
Jason M