Click here to get back home

Formatting ASCII to be read by Windows NotePad

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Formatting ASCII to be read by Windows NotePad UnRiel 07-03-2008
Get Chitika Premium
Posted by UnRiel on July 3, 2008, 5:02 pm
Please log in for more thread options
I have a nice PERL script I use to generate CISCO configurations, but
when I FTP the files to my Windows XP PC and try to read them in
Notepad, there is clearly no line wrap that Notepad understands. If I
otherwise read the file into WordPad first, save the file, then open
into Notepad, the formatting presents correctly.

I have generated the ASCII files using a simple 'print' command to a
file I generate using an 'open' command. I have tried both the newline
\n and the carriage return \r format characters.

Before I begin experiment with other characters, does anyone have a
solution for me gained from similar experience?

Thanks!

Posted by RedGrittyBrick on July 3, 2008, 5:08 pm
Please log in for more thread options
UnRiel wrote:
> I have a nice PERL script I use to generate CISCO configurations, but
> when I FTP the files to my Windows XP PC and try to read them in
> Notepad, there is clearly no line wrap that Notepad understands. If I
> otherwise read the file into WordPad first, save the file, then open
> into Notepad, the formatting presents correctly.
>
> I have generated the ASCII files using a simple 'print' command to a
> file I generate using an 'open' command. I have tried both the newline
> \n and the carriage return \r format characters.
>
> Before I begin experiment with other characters, does anyone have a
> solution for me gained from similar experience?
>

Use ASCII mode rather than binary when using FTP to transfer text files
from a Unix/Linux environment to a DOS/Windows environment. That way FTP
transforms line-endings to the ones needed by the target platform.

--
RGB

Posted by UnRiel on July 3, 2008, 7:49 pm
Please log in for more thread options
wrote:
> UnRiel wrote:
> > I have a nice PERL script I use to generate CISCO configurations, but
> > when I FTP the files to my Windows XP PC and try to read them in
> > Notepad, there is clearly no line wrap that Notepad understands. If I
> > otherwise read the file into WordPad first, save the file, then open
> > into Notepad, the formatting presents correctly.
>
> > I have generated the ASCII files using a simple 'print' command to a
> > file I generate using an 'open' command. I have tried both the newline
> > \n and the carriage return \r format characters.
>
> > Before I begin experiment with other characters, does anyone have a
> > solution for me gained from similar experience?
>
> Use ASCII mode rather than binary when using FTP to transfer text files
> from a Unix/Linux environment to a DOS/Windows environment. That way FTP
> transforms line-endings to the ones needed by the target platform.
>
> --
> RGB

Thanks to all. The ASCII mode FTP worked.

Posted by Waylen Gumbal on July 3, 2008, 6:15 pm
Please log in for more thread options
Sherman Pendley wrote:
>
> > I have a nice PERL script I use to generate CISCO configurations
>
> No need to shout - neither Perl nor Cisco are acronyms.

I don't think two all-caps words in a sentence that's otherwise properly
cased really constitutes shouting.



> > when I FTP the files to my Windows XP PC and try to read them in
> > Notepad, there is clearly no line wrap that Notepad understands. If
> > I
> > otherwise read the file into WordPad first, save the file, then open
> > into Notepad, the formatting presents correctly.
>
> Transfer the files in text mode. That will translate the line endings
> as needed.

While it is common to use ASCII mode one should still take care, as this
isn't always guarenteed to work. There used (still are?) issues with
this when uploading to MacOS based servers, for example.




--
wg



Posted by Waylen Gumbal on July 4, 2008, 12:29 am
Please log in for more thread options
Sherman Pendley wrote:
>
> > Sherman Pendley wrote:
> > >
> > > > I have a nice PERL script I use to generate CISCO configurations
> > >
> > > No need to shout - neither Perl nor Cisco are acronyms.
> >
> > I don't think two all-caps words in a sentence that's otherwise
> > properly cased really constitutes shouting.
>
> It's shouting those words.

Not in that context it wasn't.



> > > Transfer the files in text mode. That will translate the line
> > > endings as needed.
> >
> > While it is common to use ASCII mode one should still take care, as
> > this isn't always guarenteed to work. There used (still are?) issues
> > with this when uploading to MacOS based servers, for example.
>
> Such as?

I've had issues in the past uploading to a MacOS based ftp server
(remember that Mac uses \r for line endings, where as Win32 uses \r\n,
and most Linux and Unix systems use \n) and when uploading in "ASCII"
mode, the line endings became \n instead of \r (this happened with 3
different ftp clients, including the command line ftp client, so I
attribute the problem likely was the server wasn't properly telling the
client what sort of platform it was (what line endings it used.)

I'm sure theres other examples of this problem; it can come from
improperly configured ftp servers or clients too.


--
wg



Similar ThreadsPosted
How to run Perl script as GUI Windows program? Like Word, Notepad, Calculator etc. April 4, 2007, 3:43 am
[FR/EN] how to convert the characters ASCII(0-255) to ASCII(0-127) December 29, 2005, 7:33 am
How do I read a GZipped UTF-8 file from Perl on Windows? May 29, 2007, 4:24 pm
Using System to read mixed cased environment variables on Windows June 27, 2008, 2:00 pm
writing to a notepad in perl November 28, 2007, 11:32 pm
unix perl cgi notepad question December 7, 2006, 8:52 am
How to make send key ([tab] [tab]Text [Enter]) in some program (Internet Explorer or Notepad)? March 31, 2007, 3:19 am
UTF8 to ASCII? January 5, 2006, 3:49 pm
characters to ascii March 28, 2006, 10:24 pm
ASCII 0a vs 5c6e January 10, 2007, 6:27 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap