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. :scratch: any ideas please? |
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?
|
/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 |
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) ;) |
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. :) |
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. :) |
this seems similar
check this out.
https://bugzilla.redhat.com/show_bug.cgi?id=150277 Quote:
|
All times are GMT -5. The time now is 08:48 AM. |