The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
DOS/Windows CR to a UNIX LF 17 MB text file tex Windows & DOS: Issues & Discussions 9 05-22-2008 12:31 AM
how to remove ^M from windows text file in unix pragy1999 Shell Programming and Scripting 1 04-13-2006 10:04 AM
Converting Text File into XML using Unix Shell Scripts Laud12345 Shell Programming and Scripting 10 02-16-2005 01:35 PM
windows to unix text in subdirectories rein Shell Programming and Scripting 4 12-13-2004 06:42 AM
converting files from unix to windows jefft1976 UNIX for Dummies Questions & Answers 2 12-11-2001 06:29 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-13-2005
mchristisen mchristisen is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 2
Red face Converting Unix text to windows

I am trying to FTP a text file from a machine running LynxOS and I am having problems with the way windows "sees" the characters. For example this is how windows presents the text:

    DevProcRcpClass

The boxes are what I am having problems with. When viewing the same file on a Sun workstation the boxes show up as alphabetical charaters
and the spaces show up with @ symbols.

I set the transfer mode to ascii in a couple of different ftp programs and see the
same both ways. I really know nothing about unix and any help would be greatly appreciated. Thanks for your time.
  #2 (permalink)  
Old 06-13-2005
mchristisen mchristisen is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 2
Well the boxes did not show up in front of the text "DevProcRcpClass". The forums dont like it either. Anyway, windows is interpreting the characters as boxes when they really should be letters. Thanks.
  #3 (permalink)  
Old 06-13-2005
d11wtq d11wtq is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 42
Either you're tranferring the file in binary mode rather than ascii mode or you can try using this to fix your problem (sorry I'm a PHP man and don't know a better way off-hand).

Save the following as "unix2dos" filename
------------------------------------
PHP Code:
#!/usr/bin/php
<?php

$in 
$argv[1];
$out $argv[2];

$unix_data file_get_contents($in); //Read the file

$win32_data preg_replace("#\n#""\r\n"$unix_data); //Turn linebreaks into carriage returns

$handle fopen($out'w'); //Create new file for writing
if (fwrite($handle$win32_data)) { //Write the data to the new file
    
echo "\n$out created as Win32 compatible file successfully!\n";
} else {
   echo 
"\nThere has been a problem writing data to $out...\n";
}
fclose($handle); //Close the file

?>
Then simply run:

chmod +x unix2dos
./unix2dos oldfilename.txt newfilename.txt

and voila! A dos compatible file

*d11wtq moderates devnetwork php forums btw
  #4 (permalink)  
Old 06-13-2005
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,723
Unix has utilities called ux2dos (or unix2dos) and dos2ux (or dos2unix) - FWIW.

try man ux2dos
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:27 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0