Operating System - HP-UX
1834789 Members
2586 Online
110070 Solutions
New Discussion

Re: HPUX 11.23 system - C program shows LEX using FILE command

 
Tom Haddad
Super Advisor

HPUX 11.23 system - C program shows LEX using FILE command

On an HPUX 11.23 system, a co-work was programming C and inadvertantly the file was 'converted' to lexical (lex appears when I perform the FILE command). I understand 'lexical' in general but can the file be placed back to its original state?

thank you
13 REPLIES 13
James R. Ferguson
Acclaimed Contributor

Re: HPUX 11.23 system - C program shows LEX using FILE command

Hi Tom:

The 'file' command makes a best guess attempt to "describe" a file based on the first 512-bytes. If the file in question is source input for the C compiler, it only need be named with a '.c' extension to make the pre-processor/compiler "happy".

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: HPUX 11.23 system - C program shows LEX using FILE command

>JRF: The 'file' command makes a best guess

Right. I suppose you could add some comments at the top so it doesn't think it is a lex(1) input.
Or fiddle with /etc/magic? Hmm, I don't see anything there, so it must be built into file(1).
Tom Haddad
Super Advisor

Re: HPUX 11.23 system - C program shows LEX using FILE command

thanks..but when you view the file its looks at if its encrypted.!!
James R. Ferguson
Acclaimed Contributor

Re: HPUX 11.23 system - C program shows LEX using FILE command

Hi (again) Tom:

> thanks..but when you view the file its looks at if its encrypted.!!

Well, then you need to ask your co-worker exactly what (s)he did to the file.

Regards!

...JRF...
Tom Haddad
Super Advisor

Re: HPUX 11.23 system - C program shows LEX using FILE command

yea...need to do that...They were in VI but not sure of what keystrokes/command they invoked.
Dennis Handly
Acclaimed Contributor

Re: HPUX 11.23 system - C program shows LEX using FILE command

>but when you view the file its looks at if its encrypted.

Anything you can paste here to give us an idea?
Don Morris_1
Honored Contributor

Re: HPUX 11.23 system - C program shows LEX using FILE command

Encrypted + VI screams :X instead of :x. I can't even count how many times I screwed up that keystroke.

You could try using vi to open it with a decrypt key of just "Enter" (since usually :X + Enter is the sequence). Barring that, I'd be looking at a restoration from source control or a temp file (anything with name~ in the directory or the co-worker's temp directory?)
Dennis Handly
Acclaimed Contributor

Re: HPUX 11.23 system - C program shows LEX using FILE command

>Don: instead of :x. I can't even count how many times I screwed up that keystroke.

Why would you ever have problems like that? There is no such command as ":x". :-)
There is either :wq, :q, or ZZ.
James R. Ferguson
Acclaimed Contributor

Re: HPUX 11.23 system - C program shows LEX using FILE command

Hi (again):

> Dennis: There is no such command as ":x".

I think Don is referring to '-x' at the command line when 'vi' is invoked. This then asks for a "key" and encrypts the file.

Regards!

...JRF...
Don Morris_1
Honored Contributor

Re: HPUX 11.23 system - C program shows LEX using FILE command

No, I'm really referring to ":x" in command mode. Equivalent to :wq or ZZ (but faster to type). As opposed to :X (save encrypted).

Maybe I'm a younger fogey than I thought -- but I've been using that keystroke since 1990 or so at least, so I don't think it is a vim or newer vi thing. Works on every version I've ever used, after all.
James R. Ferguson
Acclaimed Contributor

Re: HPUX 11.23 system - C program shows LEX using FILE command

Hi (again):

> Don: No, I'm really referring to ":x" in command mode

Ah, I see. This *is* documented in the 'vi' manpages in an indirect way under 'zz':

"ZZ Exit the editor, writing out the buffer if it was changed since the last write (same as the ex command x)."

...which then examining the manpages for 'ex' shows that the 'X' (capitalized) is a synonym for crypt'.

Now, if you 'vi' a file and enter ":x" you save your changes and quit (exactly as you said). If, on the other hand you 'vi' and use ":X" (uppercase) you are prompted with:

Are you sure?(y/n)[n]:

...and if you answer in the affirmative, you get:

Entering encrypting mode. Key:

...and if you simply press the return key, no encryption occurs, but of course, if you enter some string, the file will be rewritten as an encrypted one when you write/save the in-memory copy. THen (obviously) to re-edit it you need to do something like:

vi -x file

...and apply the original "key".

Thanks for sharing Don!

Regards!

...JRF...
Peter Nikitka
Honored Contributor

Re: HPUX 11.23 system - C program shows LEX using FILE command

Hi,

may be, the encryption of the file (with no doubts, this file WAS encrypted) is .
If not, the user might have entered the same command again, and the result would be a used salt of
:X

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Tom Haddad
Super Advisor

Re: HPUX 11.23 system - C program shows LEX using FILE command

Problem not resolved but received some helpful input.