Debian iTOps Tube

Friday, April 27, 2012

Unix bash script (mv issues);

Hey guys,

I've registered here as I need urgent help. This is assignment for school and as you can see below I've completed the work. I'm simply stuck on one area.


This script takes the first parameter (which is to be the new extension) and each parameter after that is a file name (which will have its old extension turned into the new one). Mind you, this script works almost perfectly.

The test script (the one that grades my assignment) forces this line to call the script running from the "filderFilesAreIn" directory:


./ 'dat' 'file1.txt' 'file2.cpp' 'file3.dat' '../folderFilesAreIn/file4.dat'

My script does the first 3 files flawlessly. The 4th file, though, my code produces this output:


mv: `../folderFilesAreIn/file4.dat' and `../folderFilesAreIn/file4.dat' are the same file

It's strange as even though 'file3.dat' already exists, it replaces it with no error like above. The directory path before 'file4.dat' seem to cause the "mv -f" command to act differently.

In my code, I've used "mv -f" which is supposed to force the command to overwrite the file. This error isn't causing the program to not work but the test script (the one that grades the assignment for pass/fail) isn't letting me pass as this output is "unexpected" by it. This message is causing the script to think my code doesn't work because of the extra output.

Any help would be appreciated! I can't seem to find a way to cause "mv" to not produce any output. If I could silence the output or use another command to replace the file without getting any extra output it should count.

Thanks for your help! It's very frustrating and the teacher is being no help.

My full code is below (it's obviously not the best, but it's for a 1 credit class)

No comments:

Post a Comment