Operating System - HP-UX
1831484 Members
3388 Online
110025 Solutions
New Discussion

flip command for MSDos to Unix

 
SOLVED
Go to solution
Dale Corrington
Advisor

flip command for MSDos to Unix

I would like to use this command in HPUX. I have it on W2K. It corrects the end of line difference. How can I get this for HPUX?
10 REPLIES 10
harry d brown jr
Honored Contributor

Re: flip command for MSDos to Unix

dos2ux?

ux2dos?


live free or die
harry
Live Free or Die
Pete Randall
Outstanding Contributor

Re: flip command for MSDos to Unix

Dale,

Harry's on the money (as usual). A brief description from the man page:

dos2ux and ux2dos read each specified file in sequence and write it to
standard output, converting to HP-UX format or to DOS format,
respectively.


Pete

Pete
Dale Corrington
Advisor

Re: flip command for MSDos to Unix

That will get the job done, with some redirection, since it writes to standard output.
The flip command overwrites the existing file, and is a little less combersome.
flip -u filename

I don't know much about C, but
the source for "flip" is avaliable online. Does it just need complied for HPUX instead of Windows?

Dale Corrington
Advisor

Re: flip command for MSDos to Unix

I meant compiled, not complied.
harry d brown jr
Honored Contributor
Solution

Re: flip command for MSDos to Unix


just create a script called flip

# cat ./flip
#!/usr/bin/ksh
if [[ $1 != "-u" ]]; then
echo "ERROR. Format is"
echo "flip -u "
exit 2
fi
dos2ux $2 > $2_new$$
mv $2_new$$ $2
#


live free or die
harry
Live Free or Die
Dale Corrington
Advisor

Re: flip command for MSDos to Unix

Can do. Thanks.
Rory R Hammond
Trusted Contributor

Re: flip command for MSDos to Unix

I went out on the web and got flip.cpp.
Tried to compile but found that "nocreate" is not supported on the gcc ansi version of fstream. I modifed the ifdef else and recompiled.
A guick test shows that it works as documented.
Tested on HPUX 11i 32bit. Attached is the source and binary
compiled using
g++ -ansi -O3 flip.cpp -o flip
will need to use you will need
to
gunzip flip.cpio.gz
cpio -i < flip.cpio
Check perm
note that the cmments show how to do this in perl and sed.

Good luck
Rory
There are a 100 ways to do things and 97 of them are right
Rory R Hammond
Trusted Contributor

Re: flip command for MSDos to Unix

Looks like I could not post the binary gzip
attached is the modified source
There are a 100 ways to do things and 97 of them are right
Rory R Hammond
Trusted Contributor

Re: flip command for MSDos to Unix


Let see if you can get it as a uuencode file

uudecode < flip.uu
guznip flip.cpio.gz
cpio -i < flip.cpio

There are a 100 ways to do things and 97 of them are right

Re: flip command for MSDos to Unix

A bit more combersome than using a handy HPUX command, within the file, i.e. vi editor, you can globally remove all the dos carriage returns with the following vi substitute command:
:1,$s/^v^m//

...note, in vi, to type the ascii carriage return, ^M, you must break it down such as the carrot, ^, type V, than the M is M.

For a quick perl script that mimics the dos2ux command:
perl -pe -l.lfcr "s/[\012\015]//;" file