0

So I am trying to compile then run c++ with piped input in a shell script. I have to grade 113 programming assignments and I don't want to compile and then run test cases individually. Code:

#!/bin/bash
echo "the script starts now."
g++ Q2.cpp -o q2
./q2 < ~/scripts/t12.txt
./q2 < ~/scripts/t13.txt

Then I get the error: 'No such file or directoryt.sh: line 4: /home/stevenm/scripts/t12.txt' and 'No such file or directoryt.sh: line 5: /home/stevenm/scripts/t13.txt'

but this will work when I run it myself in the command line.

  • For debugging purposes, add `ls ~/scripts/t*txt` after the g++. Do these fles exist? – Ljm Dullaart Oct 15 '17 at 16:25
  • If your bash tells you that there is no file, then there is no file at the Location. This is not related to the programming languages at all. – harper Oct 15 '17 at 16:26
  • Notice the error message, where `No such file or directory` appears to be overrwriting the name of your script; your script has DOS line endings. – chepner Oct 15 '17 at 16:29

0 Answers0