Problem with my file...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with my file...
# 1  
Old 11-13-2009
Problem with my file...

Hi all...

I have a text file which i want to move to some remote directory...

when i use command prompt to ftp that textfile,.. after ftp if i check the file by using vi i can see many ^M with the starting and end of each line...

instead if i use grab and drop method to copy that textfile to the required directory then after if check with vi there is ^M as seen before...

what may be reason i'm getting ^M with my file when i use command prompt?
# 2  
Old 11-13-2009
so do you know dos2unix command?
# 3  
Old 11-13-2009
if you dont have dos2unix,

1. open the file in vim,
2. execute the command
Code:
:set ff=unix

3. save & exit

after this you will not get ^M in that file.
# 4  
Old 11-13-2009
The thing is first i should manually ftp the file using command prompt.. then i have a script which uses the file for its further operation...

So is it possible to use anything inside the script which removes all ^M when it takes the file during its operation...

everytime doing vi and using the above mention code is bit tough task... so pls tell me if you have any idea on this...
# 5  
Old 11-13-2009
Assuming that the file comes from a Microsoft platform, use the ASCII option in ftp. You have probably transferred the file using the BINARY option by default because the file was not recognised as a text file for some reason.
# 6  
Old 11-14-2009
So what about, dos2unix ?

Code:
15:10:07 : My Downloads :grep '^M' -l NumberToEnglish.vim # it has ^M
NumberToEnglish.vim
15:10:13 : My Downloads :file NumberToEnglish.vim
NumberToEnglish.vim: ASCII English text, with CRLF line terminators
15:10:19 : My Downloads :grep '^M' -l NumberToEnglish.vim
NumberToEnglish.vim
15:10:21 : My Downloads :dos2unix NumberToEnglish.vim
15:10:28 : My Downloads :file NumberToEnglish.vim
NumberToEnglish.vim: ASCII English text
15:10:32 : My Downloads :grep '^M' -l NumberToEnglish.vim# now it is not having that...
15:10:32 : My Downloads :

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File conversion problem

To convert file epcdic to ascill format,i am using below code.Getting some junk characters in output file.not sure what the issue is.Please correct if below command is wrong. DD conv=ascii if=filename of =output_filename. (2 Replies)
Discussion started by: srivalli
2 Replies

2. Shell Programming and Scripting

Xmllint - Xml-file problem --ods file not opening

Dear All, this is my first post on this Forum, glad to be here. I'm trying to fix an .ods file. Yes, I had a backup, but it's also corrupted. When opening the document I get this EM: read error format error discovered in the file in sub-document content.xml at 2,337040(row,col). So I... (3 Replies)
Discussion started by: jameslast
3 Replies

3. UNIX for Dummies Questions & Answers

File with -rw-r--r-- problem

Hi, I have a file on Sunos with permissions: -rw-r--r-- When I 'more' it...I get the message: *** filename: directory *** And it is acutally a directory. How come there is no 'd' shpwing on the file permission settings? Thanks (2 Replies)
Discussion started by: Grueben
2 Replies

4. Shell Programming and Scripting

Problem in test file operator on a ufsdump archive file mount nfs

Hi, I would like to ask if someone know how to test a files if exist the file is a nfs mount ufsdump archive file.. i used the test operator -f -a h almost all test operator but i failed file1=ufs_root_image.dump || echo "files doesn't exist && exit 1 the false file1 is working but... (0 Replies)
Discussion started by: jao_madn
0 Replies

5. Shell Programming and Scripting

Problem - Log File

Hi, I am in trouble ... again :wall: I formating a log file as .txt from Unix (solaris 9) and then I compress it with gzip and I use uuencode and send it in an email. gzip -c ${fic_report} | uuencode Report_File.gz > ${attachment_file} my problem is when I received the mail with the... (6 Replies)
Discussion started by: Aswex
6 Replies

6. Shell Programming and Scripting

Problem in reading a file

Hi Guys, I am having a file which does not have any name when i do a ls -l -rw-r--r-- 1 dctrdat1 dctrdata 35 Feb 09 08:04 -rw-r--r-- 1 dctrdat1 dctrdata 11961 Feb 08 06:40 DAI_data.txt Now i want to see what is inside that file. Can you please let me know how to read... (9 Replies)
Discussion started by: mac4rfree
9 Replies

7. Shell Programming and Scripting

File Spliting problem

I have a very big log file which looks like this: I need to split this file and create files with "+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" as the delimiter. The file names need to be the contents of the next line after the delimiter(FIRST_ITEM,SECOND_ITEM...so on..). (7 Replies)
Discussion started by: engineer
7 Replies

8. UNIX for Advanced & Expert Users

File access/ Never seen problem!

Dear Guru's, I am being facing strange issue in UNIX. My user name is shah and one more user name is appstest I have a directory created by appstest user i.e. /home/appstest/work ls -ld /home/appstest/work drwxrwxr-x 10 appstest apps 12288 Aug 06 23:41 /home/appstest/work Now I... (1 Reply)
Discussion started by: shahnazurs
1 Replies

9. UNIX for Advanced & Expert Users

Problem in converting password protected excel file to csv file in unix

I need to convert a password protected excel file which will be in UNIX server to a comma separated file. For this I need to open the excel file in UNIX box but the UNIX box doesn't prompt for password instead it is opened in an encrypted manner. I could manually ftp the excel file to local... (2 Replies)
Discussion started by: Devivish
2 Replies

10. UNIX for Dummies Questions & Answers

Problem writing file path to txt file

if test -z "$1" then echo "you must give a filename or filepath" else path=`dirname $1` f_name =`basename $1` if path="." then path=`pwd` fi fi cat $f_name $path >> index.txt The only problem I am encountering with this is writing $path to index.txt Keeps going gaga: cat:... (1 Reply)
Discussion started by: Vintage_hegoog
1 Replies
Login or Register to Ask a Question