Post #46,944
7/25/02 11:50:14 PM
|

Windows text files on Solaris
We're running a Perl CGI class next term and I'm trying to talk the teacher into using our Sun server to give the students a platform to upload and run their scripts from.
Apache is all set up, as is Samba. All students have accounts and the teacher has been instructed in how to mount the home directory and set up the Web folders (public_html and cgi-bin).
So far so good. However, in some testing tonight I found that Perl scripts created on Windows cause internal server errors when executed. If I remove the ^M characters at the end of each line, the scripts run correctly.
Is there any easy way to either:
- get Windows to produce a text file without the extraneous ^M's
OR
- get Apache (or perl) to ignore the ^M characters
For those who might advise setting up a Windows server instead, you miss the point.
Tom Sinclair "Subverting Young Minds Since 03/13/2000"
|
Post #46,962
7/26/02 1:46:13 AM
|

dos2unix, unix2dos
Strips/adds extraneous ^M's as necessary.
----- Steve
|
Post #47,035
7/26/02 10:59:32 AM
|

Re: dos2unix, unix2dos
Is there a way of implementing these 'in the background'. Remember, these are beginning students with little or no knowledge of UNIX (or command lines, even) working from Windows.
I was considering building a shell wrapper around perl to filter the text.
Tom Sinclair "Subverting Young Minds Since 03/13/2000"
|
Post #47,061
7/26/02 1:09:56 PM
|

I'd go this route
Having recently been bitten by two versions of this bug (a client-supplied CGI, and our own DNS zonefile generator), a wrapper to strip the CRs at some point -- file transfer, periodically in the directory, or prior to running the script, might be a good thing.
-- Karsten M. Self [link|mailto:kmself@ix.netcom.com|kmself@ix.netcom.com] [link|http://kmself.home.netcom.com/|[link|http://kmself.home.netcom.com/|http://kmself.home.netcom.com/]] What part of "gestalt" don't you understand? [link|http://twiki.iwethey.org/twiki/bin/view/Main/|TWikIWETHEY] -- an experiment in collective intelligence. Stupidity. Whatever.
Keep software free. Oppose the CBDTPA. Kill S.2048 dead. [link|http://www.eff.org/alerts/20020322_eff_cbdtpa_alert.html|[link|http://www.eff.org/alerts/20020322_eff_cbdtpa_alert.html|http://www.eff.org/...a_alert.html]]
|
Post #47,078
7/26/02 4:25:28 PM
|

I'll experiment a bit more tonight
Tom Sinclair "Subverting Young Minds Since 03/13/2000"
|
Post #46,967
7/26/02 2:37:05 AM
7/26/02 2:39:29 AM
|

Recommend a better text editor than notepad?
There are a number of shareware (maybe even freeware) text editors for Windows out there that will preserve the unix text format or convert dos2unix and back. [link|http://www.ultraedit.com/|UltraEdit] is one that comes to mind that I use.
PS: There seems to be a [link|http://ask.slashdot.org/article.pl?sid=02/07/24/1832212|discussion on Win32 editors] going on on Slashdot.
-- Chris Altmann

Edited by altmann
July 26, 2002, 02:39:29 AM EDT
|
Post #46,975
7/26/02 3:48:49 AM
|

Two more alternatives:
[link|http://www.textpad.com|TextPad] (commercial or shareware, IIRC) and [link|http://www.notetab.com|NoteTab] (shareware and freeware versions, last I looked).
I'm not *quite*, but fairly, sure that both of these can handle Unix text correctly. As for prices, I think NoteTab might be cheaper, but even TextPad can't be all that expensive -- my notoriously cheap previous employer got a site license for it.
Personally, though, I'd recommend NoteTab (regardless of price) -- the interface just feels nicer. It also has a "clip library" feature that lets you save and later insert oft-used snippets of text; and a whole bunch of HTML functionality (also for various programming languages) built-in (somehow based on those "clip libraries", I think; never much used it meself).
(OK, OK, I confess: Maybe the main reason I'm partial to NoteTab is that it's written in Delphi... :-)
Christian R. Conrad Microsoft is a true reflection of Bill Gates' personality - the sleaziest, most unethical, ugliest little rat's ass the world has seen unto this time. -- [link|http://z.iwethey.org/forums/render/content/show?contentid=42971|Andrew Grygus]
|
Post #47,019
7/26/02 9:38:53 AM
|

Faced with this problem between OS/2 and Linux . .
. . I used jed (available for most OS), because I'm used to Emacs style text based editors, but it definitely isn't for GUI hounds.
[link|http://www.aaxnet.com|AAx]
|
Post #47,036
7/26/02 11:02:53 AM
|

Definitely need freeware
Our budget is stretched too thin to even manage shareware stuff. (And we're cracking down on internal piracy, something with which most schools are rife.)
Tom Sinclair "Subverting Young Minds Since 03/13/2000"
|
Post #47,073
7/26/02 3:48:09 PM
|

Vim does well
and it's free, but you have to know or be willing to learn "vi". When you load a file, it gives you the option of using Unix or DOS format for the file.
The lawyers would mostly rather be what they are than get out of the way even if the cost was Hammerfall. - Jerry Pournelle
|
Post #47,079
7/26/02 4:26:42 PM
|

Considered that
but these are confirmed Windows monkeys.
Anyone try Jedit?
Tom Sinclair "Subverting Young Minds Since 03/13/2000"
|
Post #46,997
7/26/02 8:08:22 AM
|

Two solutions
Recent versions of Perl know to ignore the \\r's. The problem is that the shell will look for /usr/bin/perl\\r and not find it.
One solution is therefore to make /usr/bin/perl\\r a symbolic link to /usr/bin/perl. Another is to tell them to always use -w to turn on warnings.
Cheers, Ben
"... I couldn't see how anyone could be educated by this self-propagating system in which people pass exams, teach others to pass exams, but nobody knows anything." --Richard Feynman
|
Post #47,039
7/26/02 11:06:44 AM
|

Little more detail, please
is \\r a command line switch?
So, if I do
ln -s /usr/bin/perl /usr/bin/perl\\r that might take care of it automagically? What about non-DOS text scripts?
Tom Sinclair "Subverting Young Minds Since 03/13/2000"
|
Post #47,197
7/27/02 2:54:47 PM
|

Well...
I just tried it, and \\r didn't seem to be liked by the shell.
But you can do:
perl -e 'symlink("/usr/bin/perl", "/usr/bin/perl\\r")'
And then the bad scripts should work just fine.
Cheers, Ben
"... I couldn't see how anyone could be educated by this self-propagating system in which people pass exams, teach others to pass exams, but nobody knows anything." --Richard Feynman
|
Post #47,002
7/26/02 8:29:58 AM
|

Another way
FTP the files in ASCII mode.
Should fix things up in either direction.
Peter [link|http://www.debian.org|Shill For Hire] [link|http://www.kuro5hin.org|There is no K5 Cabal] [link|http://guildenstern.dyndns.org|Blog]
|
Post #47,040
7/26/02 11:09:52 AM
|

Re: Another way
Unfortunately these are Windows-bred GUI monkeys and I've already arranged for them to have their home directories on the Sun mount as network drives on their Win2K desktops.
OTOH, is there a nice GUI file transfer utility that supports sftp available? That might bear looking into.
This is getting kind of silly. I mean, there must be Perl programmers who work between Windows and UNIX all the time. What kind of hoops do they jump through?
Tom Sinclair "Subverting Young Minds Since 03/13/2000"
|
Post #47,093
7/26/02 6:44:13 PM
|

Easy peasy
just use FTP, turn on ASCII mode, and then FTP the file from Windows to the Unix box. It should do the translation for you.
If not, try that DOS2UNIX and UNIX2DOS converters.
I am free now, to choose my own destiny.
|
Post #47,102
7/26/02 7:31:37 PM
|

I think I got it
There's a text editor called CONText Pro (freeware) which allows you to set your file format to UNIX. I'll test this out and make sure it works as designed.
The added benefit is that the students will have a reasonably full-featured programming editor, rather than NotePad. If it works okay, I may recommend that this be part of the standard install.
Tom Sinclair "Subverting Young Minds Since 03/13/2000"
|
Post #47,198
7/27/02 2:57:22 PM
|

Um...
Virtually any good text editor will do this.
There are plenty of them. Including for the Windows platform Emacs, vim, GWD Text Editor, Textpad, and so on. All of which both allow you to work with files in Unix format, and give you syntax highlighting.
Cheers, Ben
"... I couldn't see how anyone could be educated by this self-propagating system in which people pass exams, teach others to pass exams, but nobody knows anything." --Richard Feynman
|
Post #47,240
7/27/02 8:28:52 PM
|

Good point
But I'm not that familiar with Windows text editors, since I don't use them myself. I only use OS X and Linux and there are plenty of options there.
However, our programming classes all either use the editor built into the IDE (VC++, etc.) or Notepad (for HTML, Javascript, Perl). The idea of having a decent standalone programmer's text editor is not yet in common parlance around these parts.
I'm doing my best, though, to introduce them to decent tools.
Tom Sinclair "Subverting Young Minds Since 03/13/2000"
|
Post #47,248
7/27/02 11:30:19 PM
|

I named several decent ones
And notepad does not count.
If they don't believe you, tell them that a good editor at a minumum should offer line numbers (when Perl tells you that there is a problem on line 431, do you count down to it?), the ability to use either line ending, and syntax highlighting. And that is a bare minimum.
You will get a list of options which are at least OK for Perl [link|http://www.perlmonks.org/index.pl?node=Outside%20Links|here]. Most are free or shareware. And, of course, if you focus on ones like [link|http://www.gnu.org/software/emacs/windows/ntemacs.html|emacs] you will get the benefit of teaching them tools that they will also find on Unix.
Cheers, Ben
PS If they are teaching Perl, HTML and JavaScript using Notepad on Windows, I dread to think about the quality of the Perl that is likely being taught. :-(
"... I couldn't see how anyone could be educated by this self-propagating system in which people pass exams, teach others to pass exams, but nobody knows anything." --Richard Feynman
|
Post #47,261
7/28/02 9:50:36 AM
|

Notepad has a goto line number function.
It's Ctrl+G. I know this because, unfortunately, I get to use NotePad to debug JavaScript in IE because that's the only editor IE thinks is installed for viewing HTML. As to why I'm using IE ... well the pages I write for have to work in IE. :-)
Wade.
"Ah. One of the difficult questions."
|
Post #47,262
7/28/02 9:58:24 AM
|

?????
all I get is nothing when I Ctrl+G in Notepad What version of Windows are you using? If you're using 2K, try MSE.exe which is even better than the downloadable environment MS offers
A
Play I Some Music w/ Papa Andy Saturday 8 PM - 11 PM ET All Night Rewind 11 PM - 5 PM Reggae, African and Caribbean Music [link|http://wxxe.org|Tune In]
|
Post #47,297
7/28/02 11:56:12 PM
|

Windows 2000.
And no, I don't use NotePad to *edit* my HTML - I use it to *view* the downloaded HTML because that's what IE calls.
Wade.
"Ah. One of the difficult questions."
|
Post #47,264
7/28/02 10:13:05 AM
|

You still don't have to use Notepad
Cut-and-paste is your friend.
Cheers, Ben
"... I couldn't see how anyone could be educated by this self-propagating system in which people pass exams, teach others to pass exams, but nobody knows anything." --Richard Feynman
|
Post #47,268
7/28/02 11:40:19 AM
|

Can't you
add another editor under the Explorer folder "folder options"/"file types"/"edit" setting for html? I did that on my Windows box, then went under IE's "Internet Options"/"programs" and Voila! there was the editor...
Ah, the 'intuitive benefits' of MS-style integration...
Imric's Tips for Living- Paranoia Is a Survival Trait
- Pessimists are never disappointed - but sometimes, if they are very lucky, they can be pleasantly surprised...
- Even though everyone is out to get you, it doesn't matter unless you let them win.
|
Post #47,296
7/28/02 11:55:03 PM
|

Ooh... didn't try that one.
Well, okay, Vim is now listed, but IE still calls up NotePad when I go view source. :-/
Wade.
"Ah. One of the difficult questions."
|
Post #47,301
7/29/02 7:16:01 AM
|

Play with the registry?
It looks to me like the choice is controled by a registry key: HKEY_CLASSES_ROOT\\.htm\\OpenWithList\\Notepad\\shell\\edit\\command
You might play with the registry and insert your prefered editor. Alternately you might just remove the section from Notepad down, and let the system ask you what you want to use.
If you do this be sure to save a copy of the registry hive first.
Hugh
|
Post #47,275
7/28/02 3:24:10 PM
|

Yes, you did and thanks
Now it's a matter of educating the educators.
Tom Sinclair "Subverting Young Minds Since 03/13/2000"
|
Post #47,311
7/29/02 9:27:46 AM
|

Ultraedit
This Windows editor understands UNIX format and so you need never worry about it. If you open a UNIX file and save it locally on Windows, it will be in DOS format. You can explicitly save in either format. IMO it's the best programmer's editor ever.
$35 USD, a great value.
-drl
|
Post #47,319
7/29/02 10:10:30 AM
|

Thanks, I made a note about it
Tom Sinclair "Subverting Young Minds Since 03/13/2000"
|