Script performs the right task but fails against check

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

  1. The problem statement, all variables and given/known data:
  1. Write a script checkFiles.sh that takes an arbitrary number of file paths from the command line and carries out the same analysis on each one, printing a line containing the file name, a colon, a blank, and then one of the two output strings from Stage 1, for each file in the command line.
    For example,

    text ./checkFiles.sh /usr/share/dict/words fileType.sh /home/cs252/Assignments/ftpAsst/d3.dat /usr/share/dict/words: Something else fileType.sh: Something else /home/cs252/Assignments/ftpAsst/d3.dat: Windows ASCII
  2. When you believe that you have your script working, run

    text ~cs252/bin/scriptAsst.pl again to check your work.
  1. Relevant commands, code, scripts, algorithms:
    I have another script called fileType.sh
#!/bin/sh                                                                       
file="$1"
case $(file "$file") in
    *"ASCII text, with CRLF line terminators" )
        echo "Windows ASCII"
    ;;
    * )
        echo "Something else"
    ;;
esac
  1. The attempts at a solution (include all code and scripts):
#!/bin/bash                                                                     
for i  in "$@"; do

    echo $i":" "`sh ./fileType.sh`"

done

I used the other code for the previous step. So for the new part, the script I wrote appears to be working, however when I test it against the teacher's checker I end up with:

Failed when running: ./checkFiles.sh 'aardvark.cpp' 'bongo.dat' 'cat.dog.bak'

I used the tag for urgent since this is due today, but if it's too late for me, I'd still love to understand this. I may fail the course (pass or fail so one fail means total fail) but that doesn't stop me from learning. Thanks ahead of time to anyone reading this!

Oh and the forum won't let me link the course since I don't have 5 post.

  1. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
    Old Dominion University, Norfolk VA USA, Professor Steven Zeil, CS252

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

When fileType.sh is working correctly for you, do you invoke it with any operands?

When you invoke fileType.sh in checkFiles.sh , what operands to you supply?

You forgot to pass the file name to fileType.sh!
I would store the `command` in a variable first, then refer the variable in the echo statement.

Tried editing the post to state I fixed the second script by adding $1 to the fileType.sh that I attempt to run. Still failing some other tests though.

fileType.sh does work properly. I had to run that for the first part of the assignment and the checker approved it but this second piece is coming back as failing some other files jay.23, king cobra.dat, and mouse.a b.

The command I ran to test is was ./checkFiles.sh [insert ascii file I have] and it gave me back the appropriate
[insert ascii file path]: Windows ASCII

If your loop control variable is $i , you probably don't want to pass $1 ...

./checkFiles.sh runs it by /bin/bash (its shebang).
Running it with sh is different. Depends on the sh how much different.