- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- howto convert text files unix2dos using perl sc...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2004 04:39 AM
тАО06-20-2004 04:39 AM
I transfer text files via ftp from LINUX to the WINDOWS ftp server using this perlscript:
......................................................................................................
my $ftp = Net::FTP->new ($server, Timeout => 9000, Debug => 3);
$ftp or die "$server: cannot connect: $@";
$ftp->login ($user,$passwd) or
die "$_: Could not login: " . $ftp->message;
# Put file
$ftp->ascii;
$ftp->put ($file) or
die "$server: cannot put $file: " . $ftp->message;
$ftp->quit;
......................................................................................................
but files after transfer are corrupt.
howto convert using perl the unix format file to dos before ftp the files ?
regards
chris
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2004 06:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2004 11:10 AM
тАО06-21-2004 11:10 AM
Re: howto convert text files unix2dos using perl script ?
I tried my hands on some perl programming (for fun & learn) and come up with a script for your unix2dos translation.
Since I don't have the FTP module for perl, I could not test it with ftp though. But the translation seem to be working. Try this snippet,
------------------
$dfile="$file.dos";
open UFILE, "<$file" or die "cannot find $file file";
open DFILE, ">$dfile" or die "cannot create $dfile file";
# ---- Translate the control characters from unix format ----
foreach $line (
$line =~ s/(?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-23-2004 12:21 PM
тАО06-23-2004 12:21 PM
Re: howto convert text files unix2dos using perl script ?
but I have a little problem to run this script:
------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
use warnings;
use Net::FTP;
use Net::Netrc;
my $server = "x.x.x.x";
my $user = "anonymous";
my $password = "";
my $destination = "/tmp";
my $file = "/home/file.txt";
my $dfile="$file.dos";
open UFILE, "<$file" or die "cannot find $file file";
open DFILE, ">$dfile" or die "cannot create $dfile file";
# ---- Translate the control characters from unix format ----
foreach $line (
$line =~ s/(?new ($server, Timeout => 9000, Debug => 3);
$ftp or die "$server: cannot connect: $@";
$ftp->login ($user,$password) or die "$_: Could not login: " . $ftp->message;
$ftp->cwd($destination);
$ftp->put($file) or die "$server: cannot put $file: " . $ftp->message;
$ftp->quit;
# ---- Delete the *.dos file ----
unlink($dfile) || die "Cannont unlink $dfile: $!";
------------------------------------------------------------
I get Error:
Global symbol "$line" requires explicit package name at test.cgi line 27.
Global symbol "$line" requires explicit package name at test.cgi line 28.
Global symbol "$line" requires explicit package name at test.cgi line 29.
Execution of test.cgi aborted due to compilation errors.
lines 27-29:
foreach $line (
$line =~ s/(?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-23-2004 05:48 PM
тАО06-23-2004 05:48 PM
Re: howto convert text files unix2dos using perl script ?
add a my $line; somewhere at the top of the script!
Put the CLOSE statements after the } such that you first print all the lines and close the files after printing.
The script will run, but the number of lines is doubled?! Use 'wc' to check, and 'od -c' to check the output file.
Better remove the \n in the print statement...
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-23-2004 06:13 PM
тАО06-23-2004 06:13 PM
Re: howto convert text files unix2dos using perl script ?
foreach my $line (
Enjoy, Have FUN! H.Merijn