Operating System - HP-UX
1827458 Members
5795 Online
109965 Solutions
New Discussion

transferring binary from windows to hpux

 
SOLVED
Go to solution
Shivkumar
Super Advisor

transferring binary from windows to hpux

Dear Sirs,

When an ascii file is transferred to hpux; sometime i have seen ^M characters at the end of the line on hpux.

If binary file is transferred via ftp in bin mode from windows to hpux then do i need to take care of anything ?

Thanks,
Shiv

22 REPLIES 22
Deoncia Grayson_1
Honored Contributor
Solution

Re: transferring binary from windows to hpux

If your file is binary and you ftping to the Hpux in binary mode then you don't have to do anything on the hpux side as it will transfer as a binary file if you want to make sure you can type bin at the ftp prompt to make sure you are in binary mode.
If no one ever took risks, Michelangelo would have painted the Sistine floor. -Neil Simon
Shivkumar
Super Advisor

Re: transferring binary from windows to hpux

Actually, my question is ascii on windows and unix are different.

is binary also different ?
Shivkumar
Super Advisor

Re: transferring binary from windows to hpux

Actually, my question is ascii on windows and unix are different.

is binary also different ?

If no; then how come binary files has been made platform independent ?
James R. Ferguson
Acclaimed Contributor

Re: transferring binary from windows to hpux

Hi SHiv:

THe "^M" character you see is the graphic representation of a carriage-return character.

Unix uses a newline (linefeed) character to denote the end of a line. Windows uses a linefeed plus carriage return couplet to do the same.

When you specify an ASCII mode FTP transfer, the conversion to add or delete a carriage return character occurs automatically. Binary mode transfers are transparent transfers. Octets are transfered "as is" and nothing is added nor deleted.

If you find that you have a file in the wrong mode, you can use 'dos2ux' or 'ux2dos' to strip or add the carriage return character. See the man pages for 'dox2ux' for more information.

Regards!

...JRF...
Arunvijai_4
Honored Contributor

Re: transferring binary from windows to hpux

Hi Shiv,

DOS text files traditionally have carriage return and line feed pairs as their newline characters while Unix text files have the line feed as their newline character. So you get ^M when you transfer windows to Unix in ASCII mode.

-Arun

"A ship in the harbor is safe, but that is not what ships are built for"
Yogeeraj_1
Honored Contributor

Re: transferring binary from windows to hpux

hi shiv,

The ASCII code is a standardized computer code which corresponds every letter, number, punctuation mark, etc. to a number between 0 and 255. This is the way computers store text files: each character in the file corresponds to a byte (8 bits, 2^8 = 256 possible combinations).

The line feed (LF) has ASCII code 10, and the carriage return (CR) has ASCII code 13. When computers first proliferated, there was some debate over how the end of lines should be stored in the file. To this day, UNIX systems use only the LF, while DOS systems use CRLF.

That is, if your file looks like this:

he
llo

UNIX would store this file as: 104 - 101 - 10 - 108 - 108 - 111
while Windows would store this file as: 104 - 101 - 13 - 10 - 108 - 108 - 111.


hope this helps too!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Shameer.V.A
Respected Contributor

Re: transferring binary from windows to hpux

Hi Shiv,

The problem is caused when a binary file ( eg: shar file) is downloaded to a pc. The pc
places
pc style end of lines in the file. The ^M is a visual representation of
the line feed not needed on unix. You can fix this by doing the
following:

# dos2ux sharfile > sharfile1
# sh sharfile1
x - README [compressed]
x - install.ksh [compressed]
x - inquiry256.1m [compressed]
x - inquiry256.ksh [compressed]
x - inquiry256 [compressed]

Hope these informations will help you..

Regards,

Shameer
.... See invisible, feel intangible and achieve impossible as everything is possible ....
Arunvijai_4
Honored Contributor

Re: transferring binary from windows to hpux

Hi Shiv,

You asked about "If binary file is transferred via ftp in bin mode from windows to hpux then do i need to take care of anything ?"

No, "bin" mode is fine for binary files. You dont need to take care of anything except checksum value.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Muthukumar_5
Honored Contributor

Re: transferring binary from windows to hpux

Problem is becuase of file format encoding. If you are getting ^M characters then file is in DOS format. To convert that use as,

# dos2ux

Use binary mode with ftp when transfer files between two different platforms.

--
Muthu
Easy to suggest when don't know about the problem!
Arunvijai_4
Honored Contributor

Re: transferring binary from windows to hpux

Hi Shiv,

If you want to remove ^M from your files,

Using Perl :
Following command will change the orginal file itself so keep a backup copy .

perl -pi -e "s:^V^M::g" existing_file_name

You won't see the Control V on typing but it is needed to generate control

character ^M.

Using sed :
sed -e `s/^V^M//g` existing_file_name > new_file_name

Using vi :
Open file in vi and enter the following at : prompt in command mode .

:%s/^V^M//g

http://www.adminschoice.com/docs/techtips.htm#Removing%20^M%20from%20unix%20text%20files

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Shivkumar
Super Advisor

Re: transferring binary from windows to hpux

Are there different types of binaries or all binaries are same ?
Arunvijai_4
Honored Contributor

Re: transferring binary from windows to hpux

Hi Shiv,

You asked "Are there different types of binaries or all binaries are same ?"

Binaries are executable files and it differs from Windows to HP-UX. Generally, Windows binaries will have .exe extension and in Unix, there is no concept of extension.

Hope this is clear.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Shivkumar
Super Advisor

Re: transferring binary from windows to hpux

My question was with respect to WebServer SSL certificate files which we consider as binary files. I was wondering the binaries which are created by compiling programs are different in what respect to the certificate files.

Regards,
Shiv
Chan 007
Honored Contributor

Re: transferring binary from windows to hpux

Shiv,

Bin files are categorised as one and same for for FTP's.

to prevent you can either use a dos2unix.

also your ftp can do mget/mput

finally use "bin" at the ftp prompt before going for transfer.

Chan
Muthukumar_5
Honored Contributor

Re: transferring binary from windows to hpux

WebServer SSL certificate files which we consider as binary files. I was wondering the binaries which are created by compiling programs are different in what respect to the certificate files

-->>>>>>>>>>>>>>>

Yes, During the transfer of the SSL certificate file it will be trasfered with same DOS encoding. So ^M characters are existing.

Best way is to transfer with bin mode as,

ftp
ftp> bin
ftp> start other commands

FTP will not care about whether it is text or executable. It will be based on mode.

--
Muthu
Easy to suggest when don't know about the problem!
Muthukumar_5
Honored Contributor

Re: transferring binary from windows to hpux

Lots of methods are there to remove ^M character.

Simply,

a) dos2ux will make it.

More methods,

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=364956

--
Muthu
Easy to suggest when don't know about the problem!
Yogeeraj_1
Honored Contributor

Re: transferring binary from windows to hpux

hi,

Your question: "Are there different types of binaries or all binaries are same ?"

Yes. Binaries are per platform in most cases. E.g. Windows binaries is not the same as HP-UX binaries is not the same as Linux binaries.

When source codes are compiled they produce binary files which are linked to libraries and other procedures that dependent on the environment/platform.

Exception Java "binaries" (bundled as jar files) that are supposed to be platform independent.

hope this helps too!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Arunvijai_4
Honored Contributor

Re: transferring binary from windows to hpux

Hi Shiv,

You asked about " My question was with respect to WebServer SSL certificate files which we consider as binary files. I was wondering the binaries which are created by compiling programs are different in what respect to the certificate files".

When you transfer webserver certificate from Windows to unix in ASCII mode, you will get ^M in certificate, To avoid this, you can transfer in bin mode.

ftp> bin
200 Type set to I.
ftp>

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Arunvijai_4
Honored Contributor

Re: transferring binary from windows to hpux

Hi Shiv,

You can simply use,
# tr -d '\015' filename

# tr -d '\r' new.file

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Arunvijai_4
Honored Contributor

Re: transferring binary from windows to hpux

Also, you can use # strings file_name > new_name

-Arun

"A ship in the harbor is safe, but that is not what ships are built for"
Arturo Galbiati
Esteemed Contributor

Re: transferring binary from windows to hpux

Hi SHiv,
this occurs because you transfer the ascii file with binary option in FTP and this will case the ^M you see in the file. To avoid this transfetr the ascii file in ascii mode and ftp will automatically convert to the rigth format or remove ^M at th unix side.
A lot of option to remove ^M:
dos2ux
vi -c "%s/^M//g|wq" filename (type ctlr V ctrl M to obtain ^M)

HTH,
Art
Bill Hassell
Honored Contributor

Re: transferring binary from windows to hpux

The term "binaries" is somewhat ambiguous. Most of the time, it refers to executable programs, but that is a special case, There are many, many other types of binary files on both Windows and Unix. For instance, the LVM status file /etc/lvmtab is a binary file because special codes are stored in the file (along with a few ASCII strings). Similarly, the ioconfig file in HP-UX is binary and none of it is readable without a special program. If you write a program to store data, you might store the data items as integers rather than ASCII strings to save disk space.

The same is true on PCs. You can safely assume that executable programs are 100% *incompatible* between machines that are running different OS's. Even among PCs, a binary exceutables are often incompatible between different versions of Windows.

As far as SSL certificates go, open one with Notepad and see if you can read it. If the text is unreadable, then it is a binary file and must be transferred in binary mode. Transferring a binary file in ASCII mode will corrupt the file.


Bill Hassell, sysadmin