Operating System - HP-UX
1826474 Members
4166 Online
109692 Solutions
New Discussion

what is lex command text ??

 
SOLVED
Go to solution
Manuales
Super Advisor

what is lex command text ??

Hi all...
what is the meaning of following word "lex" ??

>file files.pgp
>files.pgp: lex command text

i waited somethin like this:
>file files.pgp
>files.pgp: awk program text

Thanks ...
8 REPLIES 8
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: what is lex command text ??

lex is one of the programs used to build compilers and interpreters. The purpose of lex is to read a specification file so that keywords (more accurately tokens) such as "begin", "end", "if", "else", "and", "or", +, *, ... are recogized. The next step in the process uses yacc to generate code that looks for meaningful patterns of these tokens;


lex recognizes tokens "if", ">=", "then"

yacc then parses groups of these tokens
if a >= 5 then ...
to first see if the syntax is valid and then to generate ojject or p-code to act upon these instructions.
If it ain't broke, I can fix that.
Manuales
Super Advisor

Re: what is lex command text ??

Thanks ...
but ... :0(

when i run a script to crypt with pgp software, manually i run pgp command and is created a file as follows:

>ls -1 files*
files.pgp

>file files.pgp
>files.pgp: awk program text

but if this script is run from an Application, in automatical way the file is created but whey i aplied file command indicates other kind of file "lex .." when must be "awk program text as was created when was run manually :

>file files.pgp
>files.pgp: awk program text

question is: why???

Manuales.
Manuales
Super Advisor

Re: what is lex command text ??

Thanks ...
but ... :0(

when i run a script to crypt with pgp software, manually i run pgp command and is created a file as follows:

>ls -1 files*
files.pgp

>file files.pgp
>files.pgp: awk program text

but if this script is run from an Application, in automatical way the file is created but whey i aplied file command indicates other kind of file "lex .." when must be "awk program text as was created when was run manually :

Hi all...
what is the meaning of following word "lex" ??

>file files.pgp
>files.pgp: lex command text

question is: why???

Manuales.
A. Clay Stephenson
Acclaimed Contributor

Re: what is lex command text ??

The file command is taking it's best guess based upon the database stored in /etc/magic. It first looks for "magic" numbers at specified offsets into the file.
It then looks for patterns in text files.
The first match wins. Remember, file is really just guessing; it's a good guesser but ...
If it ain't broke, I can fix that.
James R. Ferguson
Acclaimed Contributor

Re: what is lex command text ??

Hi Manuales:

The word "lex" comes from "lexical" which means relating to the vocabulary or words that make up a language.

As for running 'file' against a file, what is reported is the best attempt to categorize a file by reading the first 512 bytes and comparing it to "magic" patterns. These magic patterns are actually described in 'magic' header file. See the manpages for 'file(1)' and 'magic(4)' for more information.

Regards!

...JRF...
Manuales
Super Advisor

Re: what is lex command text ??

hey !!
now, when file was created from application was created again as "awk.." instead of "lex ..." , why? i could not understand why?
problem is when file as "awk" after aply file comand is correct to be used with other scripts . but when is created as "lex .." is not work !!!

why??

i do not do nothing and was created as "awk ..." ....

please , let me know why ??

thannks... Manuales ..
A. Clay Stephenson
Acclaimed Contributor

Re: what is lex command text ??

I really can't understand what your are trying to say. I'm frankly amazed that anything run through PGP is recognized as text of any kind. What I would do is compare your original input file to an output file after being encrypted and decrypted by PGP. That is where you should be focusing not on what the file command reports. The file command again is only a guess as to what the file is; your problem is that the final file does not match the original.
If it ain't broke, I can fix that.
Bill Hassell
Honored Contributor

Re: what is lex command text ??

To amplify what Clay said, there are no file type extensions like PCs so the filename file.pgp is meaningless except that it is a name. If you read the nam page for the file command, it says what Clay wrote. I can write this note using English, then sprinkle a few Unix command names in it, insert a line with a Postscript header and this text could match any of a dozen tests -- except that it is plain English text. file may report this text as an awk program, but it isn't.

The file command works well for executable programs because they have a fairly unique set of numbers which are always the same for a specific file. But files that contain plain ASCII text cannot be identified except as ASCII text. So a Postscript file is an ASCII file. So is a script. Your PGP file may be an encrypted string but based on the tests in /etc/magic, you'll see all sorts of possibilities. The lex and awk entries in /etc/magic will match all sorts of ASCII files.

So the file command is basically useless except to decode core files.


Bill Hassell, sysadmin