How to remove junk (^Ò) character while FTPing


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to remove junk (^Ò) character while FTPing
# 1  
Old 03-25-2008
How to remove junk (^Ò) character while FTPing

Hi All,

I have been trying to FTP some data files from Windows directory to a UNIX server. The txt file in the windows contails the following data:
"111~XYZ~1~Contact person’s phone number~COMMENTS~~~~"
but the same line is appearing as
"111~XYZ~1~Contact person^Òs phone number~COMMENTS~~~~" in unix server.

The ' character is appearing as ^Ò in the unix file. Kindly suggest a way to FTP the files w/o distorting the characters.

Thanks,
# 2  
Old 03-25-2008
hi
try to ftp in binary format
or else u can remove this cheracter
open u r file in vi
then follow this
:1,$s/\^Ò//gp
i think this will help u
# 3  
Old 03-25-2008
Hi,

Try the dos2unix command in unix machine

syntax : dos2unix file_name

Last edited by apsprabhu; 03-25-2008 at 05:16 AM.. Reason: .
# 4  
Old 03-25-2008
Quote:
Originally Posted by apsprabhu
Hi,

Try the dos2unix command in unix machine

syntax : dos2unix file_name
The dos2unix command isn't there in the UNIX version I am working upon. Nevertheless thanks for the help.
# 5  
Old 03-25-2008
I tried FTPing in the binary format by using type binary on ftp prompt but still the file is being FTPed with the junk character. Also after executing the command :1,$s/\^Ò//gp in vi editor, i am getting the following error "ex: 0602-071 No match exists for the substitute pattern."
# 6  
Old 03-25-2008
dos2unix -- and FTP ASCII mode -- generally only handles line ending convention translations. The file is in a Windows character set; you need to convert it to whatever you are currently using. We can only guess what you would like it to be, and what the original character set is, but have a look at recode and iconv. If you don't have them installed locally, they are available on the Internet. Or if you have a strong stomach, use Windows and "save as" into a sane file format.

For a quick and dirty solution, find out the octal character code of the problematic character (od gives you a basic dumping facility, but it's a bit hard to read -- try piping in just a single line, rather than od:ing the whole file; or if you have xxd or hexdump, you can get more readable output, albeit in hex, not octal) and tr allows you to substitute it with something else.

Code:
vnix$ grep person.s dosfile | head -1 | od -cb
0000000   1   1   1   ~   X   Y   Z   ~   1   ~   C   o   n   t   a   c
        061 061 061 176 130 131 132 176 061 176 103 157 156 164 141 143
0000020   t       p   e   r   s   o   n 222   s       p   h   o   n   e
        164 040 160 145 162 163 157 156 222 163 040 160 150 157 156 145
0000040       n   u   m   b   e   r   ~   C   O   M   M   E   N   T   S
        040 156 165 155 142 145 162 176 103 117 115 115 105 116 124 123
0000060   ~   ~   ~   ~  \n
        176 176 176 176 012
0000065
vnix$ tr '\222' "'" <dosfile > unixfile
vnix$

I'm only using \222 as an example here; the character you want to find is most likely something else.

Don't assume there aren't other "funny" character codes in the file. As a matter of fact, there probably are.

Last edited by era; 03-25-2008 at 07:37 AM.. Reason: Clarify that 222 is just an example
# 7  
Old 03-25-2008
On another note, the vi tip would probably work if you could copy/paste the problematic sequence instead of typing in whatever it is you think you are seeing. The people here who are trying to help might not be using the same character set as you, so just to be unambiguous, it would help to know the character codes of the problematic character(s) in order to help you.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Need to remove Junk characters

Hi All, I have a issue that we are getting Junk characters from source and i am not able to load that records to Database. Line breakers Junk Characters (Â and different every time) Japanese Characters Every time I am using grep command and awk -F "\007" to find them and delete that... (1 Reply)
Discussion started by: spradeep86
1 Replies

2. Emergency UNIX and Linux Support

Help in viewing the junk character

Hello All, I have issues in unix file when I loaded that to database and do select * from table where description like '%'+char(13)+'%' on it I am able to get records. I tried to view the file in unix it is all having blank character which I think is all non ascii which I am not able view.... (11 Replies)
Discussion started by: arunkumar_mca
11 Replies

3. Shell Programming and Scripting

How to see junk character in file in.?

Hi I want to know how to see junk character in a file. i am not able to see junk character using vi or cat command. below is the junk char . which i see in host file 10.178.14.67▒▒▒ ac01sp02-vip actually it should be like this 10.178.14.67 ac01sp02-vip i am using secure CRT... (11 Replies)
Discussion started by: scriptor
11 Replies

4. Shell Programming and Scripting

removing of junk character

Dear ALL, How to remove junk charecter ^M from unix file i am using sun solaris unix. I already tried few commands :%s/^M//g :%s/r//g but it didnt helped me. Any help appriciated. Thanks Ripudaman Please view this code tag video for how to use code tags when posting code... (5 Replies)
Discussion started by: ripudaman.singh
5 Replies

5. Shell Programming and Scripting

Check Junk character in sql file

Hello, I have two .sql files which I transferred from Windows to Unix (Linux Enterprise Linux Server release 5.3).I want to ensure that these two files have no junk characters in them.How do I do it in the simplest possible way? Many thanks DJ (1 Reply)
Discussion started by: Digjoy83
1 Replies

6. UNIX Desktop Questions & Answers

Help me to remove junk char

I wanted to remove junk char in my csv. :mad: Input file format: "17","9986782190","0","D","2" "17","9900918331","0","D","2" "13","9986782194","0","A","2" Output file format 9986782190 9900918331 9986782194 And one more thing all the time "13"," this will be different Ex: . (2 Replies)
Discussion started by: Siddartha
2 Replies

7. Shell Programming and Scripting

Junk Character appended at the end of a line

Hi All I have a rather unusual problem, which i have not faced till now. I have a script which exports some paths to a text file. The script runs fine but when i check the output file i can see some junk characters ^M appended at end of lines and random places. I am not able to figure... (4 Replies)
Discussion started by: raghu_shekar
4 Replies

8. Shell Programming and Scripting

Remove all JUNK character from file.

Hi Team, I have a file having size greater than 1 GB. What i want to do is to check if it contains any JUNK character (ie any special charater thats not on the key board stroke). This file has 532 column & seperated with ^~^. I have found some solution from the file, but it is for a... (4 Replies)
Discussion started by: Amit.Sagpariya
4 Replies

9. Shell Programming and Scripting

Junk Character in file

Hi set filename "./GopiRun.sh" if } err] { writeLog "error in exec " writeLog $a } else { writeLog $a } The above code will execute a file GopiRun.sh,and will log the output of the exec to a file. The problem is the file has lot of junk character in it,how to avoid it. The... (2 Replies)
Discussion started by: nathgopi214
2 Replies

10. UNIX for Advanced & Expert Users

Get rid of junk character in a file

I have a file with one of the following lines, when opened with vi 33560010686GPT£120600GBPGBP10082007DS In the above line, I want to get rid of the junk character before the £ (pound sysmbol). When I tried copying £ from windows and copy in unix vi, it prints as £ and I tried pattern replace... (2 Replies)
Discussion started by: nskworld
2 Replies
Login or Register to Ask a Question