1834628 Members
2807 Online
110069 Solutions
New Discussion

Read text file

 
heaman1
Regular Advisor

Read text file

I have a text file and I tried to read it in different servers , A server ( which the server generate the file ) can vi and cat it , but others can't vi it but can cat it , can advise what is problem in my server ? thx
14 REPLIES 14
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Read text file

How are you trying to read the file on other servers.

If you aren't FTP'ing the file, probably there is a file permission issue.
Vibhor Kumar Agarwal
Steven Schweda
Honored Contributor

Re: Read text file

> [...] can't vi it [...]

What does this mean? Do you get some error
message, or what?

What, exactly, did you do?
What, exactly, happened when you did it?

> [...] A server [...]
> [...] my server [...]

What are these servers? "uname -a"?

Where is the file? "ls -l"?
heaman1
Regular Advisor

Re: Read text file

thx replies,


This is not permission problem , when read it , it pops below , can advise what is wrong ? thx

?^@?^@x^@m^@l^@ ^@v^@e^@r^@s^@i^@o^@n^@=^@"^@1^@.^@0^@"^@ ^@e^@n^@c^@o^@d^@i^$
^@<^@D^@o^@c^@u^@m^@e^@n^@t^@E^@l^@e^@m^@e^@n^@t^@>^@
^@ ^@ ^@<^@R^@e^@g^@D^@a^@t^@a^@>^@
^@ ^@ ^@ ^@ ^@<^@W^@a^@r^@r^@a^@n^@t^@y^@C^@a^@r^@d^@>^@0^@<^@/^@W^@a^@r^@r^@a^$
^@ ^@ ^@ ^@ ^@<^@B^@r^@a^@n^@d^@>^@K^@E^@F^@<^@/^@B^@r^@a^@n^@d^@>^@
Steven Schweda
Honored Contributor

Re: Read text file

> can advise what is wrong ?

No.

Do you ever _answer_ questions, or do you
only ask more?
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Read text file

Post the output of below:

file

On system where working/non-working (both):
which vi
alias vi
Vibhor Kumar Agarwal
heaman1
Regular Advisor

Re: Read text file

file test.txt
test.txt: Little-endian UTF-16 Unicode character data

#which vi
/bin/vi
# alias vi
bash: alias: vi: not found
Dennis Handly
Acclaimed Contributor

Re: Read text file

>file test.txt
>test.txt: Little-endian UTF-16 Unicode character data

This is NOT a HP-UX text file. Nor is it HP-UX because file(1) isn't smart enough to know anything about UTF-16.

Is one server Linux? If so, this isn't valid for HP-UX and you would have to translate it to UTF-8.
Suraj K Sankari
Honored Contributor

Re: Read text file

hi,

Did you tried like this
cat test.txt >test1.txt
then vi test1.txt

Suraj
Dennis Handly
Acclaimed Contributor

Re: Read text file

>Suraj: Did you tried like this: cat test.txt > test1.txt

I'm not sure how this will be better, especially if "diff test.txt test1.txt" says the file are the same.
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Read text file

Probably his working machine is UTF enabled or similar.
Vibhor Kumar Agarwal
Suraj K Sankari
Honored Contributor

Re: Read text file

Hi Dennis,

as he saied that he can cat the file but not able to vi the file.

Suraj
Dennis Handly
Acclaimed Contributor

Re: Read text file

>Vibhor: Probably his working machine is UTF enabled or similar.

And probably not HP-UX.

>Suraj: as he said that he can cat the file but not able to vi the file.

You are confused. He really said, that when he used vi, he got garbage. That's because vi doesn't support UTF-16, that's not a multi-byte character code sets.

If cat works, it's probably because the output is being sent back to a linux machine.
Steven Schweda
Honored Contributor

Re: Read text file

> You are confused. He really said, that when
> he used vi, he got garbage.

As _I_ recall, he said ("Apr 14, 2009
07:02:05 GMT"):

> [...] A server ( which the server generate
> the file ) can vi and cat it , but others
> can't vi it but can cat it [...]

I _asked_:

> What are these servers? "uname -a"?

with no apparent result.

Most likely, one of the "vi" programs is
smarter than the other (perhaps by being
"vim" instead of "vi"), but given the
unidirectionality of the information flow
here, we may never know.
Dennis Handly
Acclaimed Contributor

Re: Read text file

>Steven: As _I_ recall

You have to read more replies (and minds :-), "when read it, it pops below" and "Little-endian UTF-16 Unicode".