4

I am trying to run the following script.

#!/bin/csh
# USAGE EXAMPLE: solve_mysteries.scr ops6.txt 2
# USAGE EXAMPLE: solve_mysteries.scr allops.txt 1800
set opsfile = $1
set maxtime = $2
set f = $3

set outfile = brute_solutions.dat
set outfile2 = brute_constant.dat
set outfile3 = brute_formulas.dat
if -f $outfile /bin/rm $outfile
if -f $outfile2 /bin/rm $outfile2
if -f $outfile3 /bin/rm $outfile3

echo Trying to solve mysteries with brute force...

echo Trying to solve $f...
echo /bin/cp -p $f mystery.dat
/bin/cp -p $f mystery.dat
echo $opsfile arity2templates.txt mystery.dat results.dat >args.dat

timeout {$maxtime}s ./symbolic_regress3.x

I get the following output

^M: Command not found.
^M: Command not found.
Trying to solve mysteries with brute force...
^M: Command not found.
...ing to solve ../example_data/example2.txt_train
 mystery.dat./example_data/example2.txt_train
/bin/cp: cannot stat '../example_data/example2.txt_train'$'\r': No such file or directory
^M: Command not found.
timeout: invalid time interval ‘60\rs’
Try 'timeout --help' for more information.
^M: Command not found.

Any idea why I am getting this "^M: command not found" error?

2 Answers2

3

cat -v script shows you that at least some of the lines have a CR (carriage return) character, probably at the end.

Your script is a text file in DOS/Windows format. You need to convert it to Unix format (i.e. remove the CRs). This can be done by editors or e.g. the tool dos2unix.

Hauke Laging
  • 90,279
0

If you can download Sublimetext, which is an text editor, you can change the line endings from View->LineEndings->Unix

Then save the file and try running it again.

Fra93
  • 149