Sponsored Content
Full Discussion: ftp the file
Operating Systems AIX ftp the file Post 302141218 by bakunin on Thursday 18th of October 2007 06:28:26 AM
Old 10-18-2007
The reason is that the end of a line is represented differently in DOS and UNIX. In DOS (and similar OSes) the end of a line is represented by two characters: CR (carriage return) and LF (line feed). his is much like the behaviour of a typewriter (the archetype of computer files), where at the end of a line, you wouls swing back the writing head to the beginning of the line (CR) and then feed some amount of paper to not overwrite the same line but write below it on the next (LF).

So, when you see some text in DOS (like in notepad or so) which looks like:

Code:
line 1
line2

in fact this would be the following succession of bytes:

line 1<CR><LF>line2<EOF>

Look at the file using a hex editor and you will see what i mean.

In UNIX the situation is differently: There is a special end-of-line-character, which denotes the end of a line. The same file under UNIX would look like (try it out by using the "od -ax" command)

line 1<EOL>line2<EOF>

Utilities like dos2unix do nothing else than convert the one format into the other by changing the <CR><LF>-sequences to <EOL>-characters and vice versa.

You don't even need these utilities when you transfer the file with ftp using the ASCII-mode instead of the binary mode. This is exactly the difference between the two. "Binary" means "do not exchange any CR/LF characters to <EOL> and vice versa" and "ASCII" means "do exchange..."

When you transfer the file in compressed format the ftp program will not recognize the ASCII format, because the compressed file is a binary file. Otherwise, when you transfer the text file in its natural form, many ftp-clients recognize it as text and switch to ASCII mode automatically, if yours does not you can simply switch yourself by issuing the "as" subcommand (and the "bi" subcommand to get back to binary mode again).

If you have transferred the file already and do not want to retransmit it you can easily change the file with sed:

sed 's/^M$//' file > file.changed

To enter the CTRL-M-char from the command line you can enter <CTRL>-V and then <CTRL>-M (hold down the <CTRL> key while pressing V or M respectively).

bakunin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

FTP script to FTP file to UNIX - Solaris

Hello, A couple of times per week, i receive emails notifications when files are available for processing. Currently i read these eamails with a java program and store the attachement on my C: drive and would now like to generate a PC script to send this file name up to UNIX-Solaris and... (3 Replies)
Discussion started by: bobk544
3 Replies

2. Shell Programming and Scripting

how to put file from one ftp to another ftp location

hi, I have one file located in ftp.I want to place that file in different ftp location. Up to now i am doing it manually using get command and copying that file in to my local system and then putting that file in different ftp using put command. now i want to automate that using shell... (1 Reply)
Discussion started by: prasee
1 Replies

3. UNIX for Advanced & Expert Users

Using FTP to check whether file is completely FTP... plz find the description below

Hi, We have some clients who will place huge files in to one of the remote server. And the shell script written in our local server to retrieve client files (using FTP) placed on one of the remote server of ours by clients. My question Is there any FTP command/script to check from my local... (1 Reply)
Discussion started by: nmsrao
1 Replies

4. Shell Programming and Scripting

Deleting File from FTP and Transferring File to FTP

Hi, I am getting error when i am deleting file from FTP and also transferring file from local to FTP server. I am getting 221 error. I am getting this error some time only. Some time the existing file from FTP is deleted and file from local directory is transferred to FTP server. ... (2 Replies)
Discussion started by: praka
2 Replies

5. HP-UX

[Solved] Unable to rename file in ftp server .Net:FTP perl

Hello All, I am trying to connect to ftp server and get the files. Also i need to rename the file in other ftp dir. rename method is not allowing me to rename the file in other dir. When i tried copy command by using net::FTP:FILE then perl says it is not installed. Can some body help me to... (2 Replies)
Discussion started by: krsnadasa
2 Replies

6. Shell Programming and Scripting

How to ftp multiple files by taking the file name from a input file.

Hi, I'm working on a script which has to copy multiple files from one server to another server. The list of files that are to be copied is present in a file say input.txt. vi input.txt abc.c welcome.c new.c welcome1.c for ftp'ing a single file say 'new.c' the following code... (2 Replies)
Discussion started by: i.srini89
2 Replies

7. Shell Programming and Scripting

Needed script to FTP a File and generate a quality checksum file

hi all i want a script to FTP a file and should generate a quality checksum file means when I FTP a file from one server to another server it should generate a QC file which should contain timestamp,no.of records in that file Thanks in advance saikumar (3 Replies)
Discussion started by: hemanthsaikumar
3 Replies

8. Shell Programming and Scripting

List the file names available on FTP server before selecting the required file

Below is my script code.which shows the environment name and then fetch the file from the ftp server but I am facing one issue.The script should be run in both way.We can pass the arguments with script and select the environment name then file name.Here the issue is I am not able to list the files... (1 Reply)
Discussion started by: anuragpgtgerman
1 Replies

9. Shell Programming and Scripting

Ftp bash script appends to file using cron instead of coping new file

I have a bash script that is running a mysql query and creating a csv file with a time stamp. It then uploads that to a ftp server. Everything works great when I manually run it. But then I have a cron job set to run every monday, wednesday and friday at 5am est. When the cron job runs, it... (7 Replies)
Discussion started by: akallenberger
7 Replies

10. UNIX for Dummies Questions & Answers

After Ftp'ing file to destination how to check the file if it is in correct ASCII and not corrupted

Hi Folks, While transferring file from FTP software like Filezilla the files gets corrupted. Is there any way I can check if the recently transferred file is in ASCII and not corrupted. I have tried using file -i filename command which does tell if the file character set is ASCII or binary... (6 Replies)
Discussion started by: Khan28
6 Replies
This  is  a  slightly  lobotomized kermit.  The help command, the
script facility, and the automatic dial  support  have	been  re-
moved.	The ? and ESC commands still work, so there is still rea-
sonable built-in help.	The only V7 kermit feature that does  not
work  is  the  ability	to see whether there are input characters
waiting.  This means that you will not be able to ask for  status
during a file transfer (though this is not critical, because ker-
mit prints a dot every so  often  and  other  special  characters
whenever  there  is an error or timeout).  Start kermit, and then
type the following to open a 2400 baud session, for example:
(It is more convenient if you put these commands  in  .kermrc  in
your home directory, so that they get done automatically whenever
you run kermit.)  This will connect you to the modem or  whatever
on  the  serial  port.	 Now log into the other system.  When you
want to transfer files, run kermit on the other system.   To  it,
type  This puts its kermit into a sort of slave mode where it ex-
pects commands from the kermit running on your MINIX system.  Now
come back to the command level on MINIX kermit, by typing the es-
cape character followed by c.  (Kermit will tell you the  current
escape character when you do the connect command.)  At this point
you can issue various  commands.   Your  kermit  will  coordinate
things	with kermit on the other machine so that you only have to
type commands at one end.  Common commands are
Filenames can include wildcards.  By default, kermit works  in	a
system-independent,  text  mode.   (In effect it assumes that the
whole world is MS-DOS and converts end of line and file names ac-
cordingly.)   To send binary files, you will want to type on both
ends before starting any transfers.  This disables CR LF to  new-
line  conversion.   If	both  of  your systems are some flavor of
UNIX, you might as well put this in .kermrc on both ends and  run
in  binary  mode all the time.	Also, if both systems are UNIX it
is recommended that you use on both ends.  This causes it to keep
file  names unchanged, rather than mapping to legal MS-DOS names.
Here is a typical .kermrc for use on
On the other end of the line, for example, the host at your local
computer  center  to  which you want to transfer files, a typical
profile might be:
Kermit has many other options and features.  For a  pleasant  and
highly readable description of it, see the following book:
  Title: Kermit: A File Transfer Protocol
  Author: Frank da Cruz
  Publisher: Digital Press
  Date: 1987
  ISBN: 0-932376-88
For  information  about  recent kermit developments, versions for
other systems, and so forth, please contact:
  Christine M. Gianone
  Manager, Kermit Development and Distribution
  University Center for Computing Activities
  Columbia University
  612 West 115th Street
  New York, N.Y. 10025
Over 400 versions of kermit are available, so it is likely  there
is  one  for any computer your system might want to talk to.  Co-
lumbia University also publishes a newsletter about  kermit  that
can be requested from the above address.
All times are GMT -4. The time now is 04:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy