Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying from floppy can't execute

Status
Not open for further replies.

coper

Technical User
Jan 4, 2002
36
US
Hello,
Why when I copy .cgi or .pl files to floppy from my windows pc and load onto linux box I can't execute them even if I make executable. However if I ftp the file to server it works! Any clues what causes this. I'm thinking when copying file floppy there are spaces ^M being added or something to that affect going on.

Thanks
 
Hi,

This would be because dos/windows machines employ a different line-end than unix/linux. On dos you get two bytes - a carriage return (x'0D') and a line feed (x'0A') whereas a linux system only has the line feed (x'0A').

When you transfer via ftp, most ftp clients will automatically do the conversion if you transfer as 'text' (vs binary) so this explains why it works that way . Copying via floppy would preserve the crlf (x'0D0A') which would not be recognised properly in linux.

Hope this helps
 
There are also programs that will do this conversion for you. 'dos2unix', which will strip the ^M's, and allow you to execute the program. I use it quite often, when downloading patch files on a windows machine, and copying it over to a linux box.

dos2unix comes with RH 7.1, and 7.2, but you can probably build it from source if you had to for your distro. Search rpmfind.net for it. Bruce Garlock
bruceg@tiac.net
 
If you have a good Windows text editor, such as UltraEdit ( you can usually convert between the Unix/Win/Mac platforms before saving. -------------------------------------------

"Calculus is just the meaningless manipulation of higher symbols"
                          -unknown F student
 
I usually just do a quick search and replace using vi or if I'm feeling lazy sed.

If your interested in the syntax let me know otherwise I will not post it.
-Danny
techie@snoboarder.net






 
The reason why you cannot execute that file even though it has 777 permissions on it is because the file itself is recognized as DOS file.

Check this by executing command: file <your_file_name>
you will see it says something like: DOS file...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top