Operating System - HP-UX
1753777 Members
7674 Online
108799 Solutions
New Discussion юеВ

Re: FTP ^M character problem.?? hp-ux 11i

 
SOLVED
Go to solution
Raj D.
Honored Contributor

FTP ^M character problem.?? hp-ux 11i

Hi I am uploading a script from my windows pc to HP-UX server.

FTP> bin
mput script.sc

After loggin in to the hp-ux server I found that the found filled up with "^M" characters each line.

How to remove this unnecessary characters from the file. Ant script or something can help me.

Thanks in advance ,

Regards,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
4 REPLIES 4
Biswajit Tripathy
Honored Contributor

Re: FTP ^M character problem.?? hp-ux 11i

Since this is a text file, you should use ascii instead
of bin.

FTP> ascii
200 Type set to A.
FTP> put script.sc

- Biswajit
:-)
rveri
Super Advisor
Solution

Re: FTP ^M character problem.?? hp-ux 11i

Hi Raj ,

You can try this to filter out the undesirable characters:

$ tr -cd '\11\12\40-\176' < script.sc > script1.sc

script1.sc will be the new file , without any control characters.

Cheers ,

R.Veri.
Biswajit Tripathy
Honored Contributor

Re: FTP ^M character problem.?? hp-ux 11i

You could use R Veri's solution to remove the ^M
chars, but the core of the problem is that the file
is not transfered properly. ^M is interpreted as
end-of-line char in windows. When you ftp the file
to HP-UX as a binary file, the ^M char is transfered
to HP-UX as is. As ^M is not interpreted in HP-UX
as end-of-line, so it is just displayed as part of the
file. Same must be true for end-of-file char (look at
the end of your file in HP-UX).

The "correct" way to fix this is to tell FTP that the
file type is "ascii" and not "bin" (as shown in my
previous reply in this thread) and it will handle it for
you.

- Biswajit
:-)
Patrick Wallek
Honored Contributor

Re: FTP ^M character problem.?? hp-ux 11i

There is also the dos2ux function that will take care of this.

# dos2ux script.sc > script.sc1
# mv script.sc1 script.sc