SFTP是作为SSH一部分的FTP子系统,它允许你进行加密的文件传输。在过去的一周里,我遇到了两个关于SFTP不能正确传输文件的问题。在一个案例中,OpenVOS是文件的来源,而在另一个案例中,OpenVOS正在接收文件。在这两种情况下,文件都包含ASCII数据,问题与Microsoft Windows和OpenVOS在文本文件中终止行的方式不同有关。
让我们从OpenVOS作为源头开始。如果你用你喜欢的编辑器创建一个文本文件,你就会创建一个连续的文件。比如说
d test %phx_vos#m16_mas>SysAdmin>Noah_Davids>test 10-09-05 08:13:49 mst 12345 67890
|
display_file_status test name: %phx_vos#m16_mas>SysAdmin>Noah_Davids>test file organization: sequential file . . . next byte: 20 blocks used: 1 . . . record count: 2 data byte count: 10
|
dump_file test %phx_vos#m16_mas>SysAdmin>Noah_Davids>test 10-09-05 08:14:07 mst区块编号1000 00053132 333435FF 00050005 36373839 |..12345…..6789|010 30FF0005 0...............|020 FFFFFFFF FFFFFFFF FFFFFFFF |................| FFFFFFFF FFFFFFFF FFFFFFFF |................| = FF0 FFFFFFFF FFFFFF FFFFFFFF |................| 准备好 08:14:07 |
C:Documents and SettingsnoahMy Documentstemp>"C:Program FilesPuTTYpsftp" [email protected] Using username "nd". [email protected]'s password: Remote working directory is /SysAdmin/Noah_Davids psftp> get test test.txt remote:/SysAdmin/Noah_Davids/test => local:test.txt psftp> quit C:Documents and SettingsnoahMy Documentstemp>dir Volume in drive C has no label. Volume Serial Number is 38B1-9C13 Directory of C:Documents and SettingsnoahMy Documentstempblog - sftp 08/27/2010 01:50 PM <DIR> . 08/27/2010 01:50 PM <DIR> .. 08/27/2010 01:50 PM 12 test.txt 1 File(s) 12 bytes 2 Dir(s) 39,471,644,672 bytes free |
%phx_vos#m16_mas>SysAdmin>Noah_Davids>pc1.txt 10-09-05 08:52:21 mst 000 61626364650D0A666768696A0D0AFFFF|abcde...fghij....| 010 FFFFFFFF FFFFFF FFFFFF FFFFFFFF |................| = FF0 FFFFFFFF FFFFFF FFFFFFFF |................| 准备好 08:52:21 |
%phx_vos#m16_mas>SysAdmin>Noah_Davids>pc1.txt 10-09-05 08:54:25 mst abcde fghij 准备好 08:54:25 |
test_system_calls tsc: s$attach_port p pc1.txt tsc: s$open tsc: s$seq_read p Buffer length = 6 00000000 61626364 650D |abcde. | tsc: s$seq_read p Buffer length = 6 00000000 66676869 6A0D |fghij. |
|
# cr.pl begins here # # cr # version 1.0 10-08-27 # use strict; use warnings; use Getopt::Long; my ($inFile, $outFile, @files, $add, $remove); my ($INFILE); my ($result, $count, $verbose, $addremove); $result = GetOptions ('in=s' => $inFile, 'out=s' => $outFile, 'add' => $add, 'remove' => $remove, 'verbose=s' => $verbose); if (($result != 1) || !defined ($inFile) || !defined ($outFile)) { print "nnUsage:n"; print "perl cr.pl -in PATH -out PATH [[-add] | [-remove]] [-verbose]}n"; exit; } if (defined ($add) && defined ($remove)) { print "You can only specify -add or -remove not bothnn"; print "nnUsage:n"; print "perl cr.pl -in PATH -out PATH [[-add] | [-remove]] [-verbose]}n"; exit; } @files = glob ($inFile); if (@files < 1) {print "nNo files found for " . $inFile . "nn";} if (@files > 1) {print "nMore than 1 file found for " . $inFile . "nn";} open (OUT, ">".$outFile) || die "Can't open output file " . $outFile . "nn"; open ($INFILE, $files[0]) || die "Can't open input file " . $files[0] . "nn"; if (!defined ($verbose)) { $verbose = -1; } $count = 0; while ($_ = <$INFILE>) { if (defined ($remove)) { s/r//; print OUT $_ ; } else { s/n//; print OUT $_ . "rn"; } $count++; if (($verbose > 0) && ($count % $verbose) == 0) { print "Line " . $count . " of " . $files[0] . " processedn"; } } close $INFILE; #
|