I use a php script to generate a LaTeX file (report.tex) on my local OSX 10.6.7 with MAMP (tThe filesystem is HFS+).
Then I use exec()
to build the file using LaTex. The .tex is well created on the filesystem, but it is not recognized as a .tex file by the finder, nor by LaTex.
I've checked that the problem is not in the file itself, but in the way the php script has created it.
Indeed, if I use a text editor to create report.tex, the file is correctly handled by the system and makes no problems with LaTex. If I run the php script, it creates another file, with the same name(!), in the same dir.
Internally, these files are exactly the same, checked with an hex editor.
If I run an ls -ls@
in the dir, I obtain
8 -rw-r--r--@ 1 tom staff 871 4 jui 12:30 report.tex
com.apple.FinderInfo 32
com.apple.TextEncoding 15
8 -rw-r--r-- 1 tom staff 805 4 jui 12:35 report.tex
The last file is the php-generated one. If I run xattr -p com.apple.FinderInfo
on the first file, I get
54 45 58 54 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
and if I run xattr -p com.apple.TextEncoding
,
UTF-8;134217984
I can open the second file without problems, once the text editor is specified (this file is not recognized as a .tex but the first one is!). The file then shows fine in TextWrangler, but the syntax coloration of tex is not activated (it is activated for the first one and their contents are the same bytewise).
I'm pretty sure these problems are related to this extra attribute thing. My question is : is there a way, with PHP or OSX, to achieve a correct behavior, that is the file created by php is recognized as a normal .tex file and for example, overwrites the first one (and of course can be processed by LaTex)?
Regards,
Tom
The extended attributes are a red herring since files in a directory are not differentiated by their attributes, only their name. So you cannot have two files with the same name in the same directory. Almost certainly the problem is that one of the file names has an unprintable character in it, most likely a space. Here's an example:
$ echo "hi" >"a.php"
$ echo "hi" >"a.php "
$ ls -l
total 16
-rw-r----- 1 nad wheel 3 Jun 4 10:03 a.php
-rw-r----- 1 nad wheel 3 Jun 4 10:03 a.php
$ for f in * ; do echo ">$f<" ; done
>a.php<
>a.php <
You can do something similar to check the file name. Check your PHP code for how you create the file name.