| Category: | linux administration |
| Author/Contact Info | Jerry Fowler - jerry at digilliance.net |
| Description: | A very useful block of code for web server administrators. Converts DOS format files uploaded in BINARY mode to UNIX format by stripping the Control M characters. Usage: Copy to /usr/bin/stripline, chmod to 755, then you (or any user) can: to fix a mis-uploaded file. Disclaimer: This could be considered reinventing the wheel as there are code snippets around that do the same function. This one is however set up especially for use as a system utility. |
#!/usr/bin/perl
use strict;
if ($ARGV[0] eq undef) {
print "stripline (GNU GPL)\nSept 15, 2001 Jerry D. Fowler jerry\@digi
+lliance.net\n";
print "Usage: stripline in.file out.file\n\n";
exit;
}
chdir($ENV{PWD}) or die "Could not change to your current directory\n"
+;
open (FILE, "$ARGV[0]") or die "Could not create Outfile";
open (OUT, ">$ARGV[1]") or die "Could not create Outfile\n";
while (<FILE>) {
$_ =~ s/\cM//g;
chomp;
print OUT "$_\n";
}
close FILE;
close OUT;
|
|
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: stripline
by rob_au (Abbot) on Sep 16, 2001 at 07:23 UTC | |
|
Re: stripline
by Rex(Wrecks) (Curate) on Sep 24, 2001 at 21:02 UTC |