LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-09-2006, 11:23 PM   #1
smilingdragon
LQ Newbie
 
Registered: Oct 2006
Location: Wellington, New Zealand
Distribution: Suse 9
Posts: 5

Rep: Reputation: 0
Question unix2dos problems renaming converted file


When I run unix2dos from crontab in suse linux it fails to rename the temporary file created for the conversion.

unix2dos -ascii -n /opt/oracle/admin/scripts/logs/test_file1.lst /opt/oracle/admin/scripts/logs/test_file2.lst

The output shows the following:

unix2dos: converting file /opt/oracle/admin/scripts/logs/test_file1.lst to file /opt/oracle/admin/scripts/logs/test_file2.lst in DOS format ...
unix2dos: problems renaming './u2dtmpqRR8kv' to '/opt/oracle/admin/scripts/logs/test_file2.lst'
output file remains in './u2dtmpqRR8kv'
unix2dos: problems converting file /opt/oracle/admin/scripts/logs/test_file1.lst to file /opt/oracle/admin/scripts/logs/test_file2.lst

The temporary file './u2dtmpqRR8kv' ends up in the home directory.

I think this must be a permissions or possibly a env variable problem as this script works on the other suse linux servers.

I have done some testing to try and pinpoint the problem but am getting frustrated now.

any ideas please?
 
Old 10-10-2006, 06:16 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Check access rights for your user on file /opt/oracle/admin/scripts/logs/test_file2.lst and dir /opt/oracle/admin/scripts/logs? If that's not it, what does `file /opt/oracle/admin/scripts/logs/test_file1.lst` return?
 
Old 10-10-2006, 03:34 PM   #3
smilingdragon
LQ Newbie
 
Registered: Oct 2006
Location: Wellington, New Zealand
Distribution: Suse 9
Posts: 5

Original Poster
Rep: Reputation: 0
/opt/oracle/admin/scripts/logs/test_file2.lst doesn't exist until the conversion completes. (on the other server it is 600)

/opt/oracle/admin/scripts/logs/test_file1.lst is 644

/opt/oracle/admin/scripts/logs is 755

file test_file1.lst returns : ASCII text, with very long lines

file test_file2.lst on the other server returns : ASCII text, with very long lines, with CRLF line terminators
 
Old 10-10-2006, 04:42 PM   #4
smilingdragon
LQ Newbie
 
Registered: Oct 2006
Location: Wellington, New Zealand
Distribution: Suse 9
Posts: 5

Original Poster
Rep: Reputation: 0
Still not sure why it won't work from crontab, but I now have it working from Oracle OEM.

Thanks for the help.

Might put this one down to a UFW (Unidentified Flying Wobbly)
 
Old 04-14-2008, 05:40 PM   #5
smilingdragon
LQ Newbie
 
Registered: Oct 2006
Location: Wellington, New Zealand
Distribution: Suse 9
Posts: 5

Original Poster
Rep: Reputation: 0
solved it

It turns out that when you run the script from cron your current directory (PWD) is set to your home directory. Unix2dos creates the temporary file used in the conversion in your home directory then can't find it to rename it. Not sure why it can't find it.

I added a change directory command (cd) and Unix2dos worked.
 
Old 04-15-2008, 06:20 PM   #6
smilingdragon
LQ Newbie
 
Registered: Oct 2006
Location: Wellington, New Zealand
Distribution: Suse 9
Posts: 5

Original Poster
Rep: Reputation: 0
recode

I have been searching the forums for information on why unix2dos behaves as it does and can't say that I had much success.

However I did find mention of the utility recode which is a replacement for unix2dos and dos2unix.

I replaced the unix2dos command with the following:

cp -p test1.txt test2.txt
recode lat1..dos test2.txt

The main difference seems to be that you don't specify a source file and a destination file. (Please correct me if I am wrong.) So I make a copy first and modify the copy. Also you need to specify the characterset. lat1 seems to be the characterset for the linux file and dos is the windows one. So to do the dos2unix it would be dos..lat1.

Anyway recode worked very well from cron and I had no problems with it. Now I just need to convert several scripts to use this instead.

 
Old 12-31-2008, 05:35 AM   #7
jaewoong.kim
LQ Newbie
 
Registered: Dec 2008
Posts: 4

Rep: Reputation: 0
this seems similar

check this out.
https://bugzilla.redhat.com/show_bug.cgi?id=150277

Quote:
Bug List: (This bug is not in your last search results) Show last search results
Bug 150277 - problems renaming tmpfile to outfile
Status: CLOSED RAWHIDE
Product: Fedora
Component: dos2unix (Show Fedora/dos2unix bugs)
Version: 3
Platform: All Linux
Priority: medium Severity: medium
Target Milestone: ---
Assigned To: Tim Waugh
QA Contact: Ben Levenson
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
Show dependency tree

Reported: 2005-03-04 02:22 EDT by Stephen Beahm
Modified: 2007-11-30 17:11 EDT (History)
Fixed In Version: 3.1-24
Release Notes:
Restrict Group Visibility:
Only users in any of the selected groups can view this bug:
(Unchecking all boxes makes this a more public bug.)
Current Groups: (edit)
None Set

Attachments
Patch for this problem (422 bytes, patch)
2005-09-29 08:50 EDT, Wojciech Milek Details | Diff
View All Add an attachment (proposed patch, testcase, etc.)


External Bugs


Description From Stephen Beahm 2005-03-04 02:22:01 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3)
Gecko/20041020 Epiphany/1.4.4

Description of problem:
The problem is in 'dos2unix-3.1-tmppath.patch'. Memory for the null
terminator is not being allocated.

this code:
fname_len = strlen(dir) + strlen("/d2utmpXXXXXX");

should be:
fname_len = strlen(dir) + strlen("/d2utmpXXXXXX") + sizeof(char);

Version-Release number of selected component (if applicable):
dos2unix-3.1-21

How reproducible:
Sometimes

Steps to Reproduce:
1. dos2unix ./source/common/launch.h



Actual Results: dos2unix: converting file ./source/common/launch.h to
UNIX format ...
dos2unix: problems renaming './source/common/d2utmptfS3dJ' to
'./source/common/launch.h'
output file remains in './source/common/d2utmptfS3dJ'

Additional info:
 
  


Reply

Tags
suse9



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to insert newlines into a dd-converted ascii file bryan.out.there Linux - General 2 09-13-2006 11:42 PM
File renaming amushtaq Linux - Software 2 01-13-2006 05:40 AM
renaming a file?? U-Toast Linux - Newbie 2 08-29-2004 01:07 AM
unix2dos not found Big Al Slackware 4 07-19-2004 03:25 PM
renaming or converting a text file to a dat file... tangaz Linux - Software 1 10-24-2003 06:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration