Linux + create and write file

how create and write file on the Linux. code which i use in windows not work in Linux, thanks.

[code=html]
function writeFile( filename, content)
{
try
{
var file = Components.classes[“@mozilla.org/file/local;1”].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath( filename );
var outputStream = Components.classes[“@mozilla.org/network/file-output-stream;1”].createInstance( Components.interfaces.nsIFileOutputStream );
outputStream.init( file, 0x04 | 0x08 | 0x20, 420, 0 );
var result = outputStream.write( content, content.length );
outputStream.close();
}
catch(err){}
}

I would have the javascript make a remote call to a server side script via AJAX. To me, it seems a heck of a lot easier to do it that way.

Ok. I am toolbar developer, but i never work with ajax. may be you have some example for me or native links. Thanks.