1

I am new in windows 10 and Bash on Ubuntu and not familiar with shell script . I have to run this shell script

#!/bin/bash -x
mkdir -p lib
mkdir -p bin
cd nnforge
make $@
cd plain
make $@
cd ../cuda
make $@
cd ../..
cd examples
for i in ./*
do
    if [ -d "$i" ];then
        cd $i
        make $@
        cd ..
    fi
done
cd ..
cd apps
for i in ./*
do
    if [ -d "$i" ];then
        cd $i
        make $@
        cd ..
    fi
done
cd ..

But when I run this script with Bash, this show this errors

+ mkdir -p $'lib\r'
mkdir: cannot create directory ‘lib\r’: No such file or directory
+ mkdir -p $'bin\r'
mkdir: cannot create directory ‘bin\r’: No such file or directory
+ cd $'nnforge\r'
: No such file or directorynnforge
+ make $'\r'
./make_all.sh: line 5: make: command not found
+ cd $'plain\r'
: No such file or directoryplain
+ make $'\r'
./make_all.sh: line 7: make: command not found
+ cd $'../cuda\r'
: No such file or directory../cuda
+ make $'\r'
./make_all.sh: line 9: make: command not found
+ cd $'../..\r'
: No such file or directory ../..
+ cd $'examples\r'
: No such file or directory examples
./make_all.sh: line 13: syntax error near unexpected token `$'do\r''
'/make_all.sh: line 13: `do

How can I fix this and run script properly?

1
  1. This script is compiled in such a way that matters where it is running. Make sure that you run the script from the folder in which the present nnforge folder.
  2. Another possible problem - a newline character. Try to convert newline characters in your script in unix format: sudo apt-get install tofrodos dos2unix <your script full name>
  3. Your system does not have a make command to install it, and others probably necessary commands do the: sudo apt-get install build-essential

P.S. But if you try to build nnforge i'm afraid you will not get results in Windows 10 Bash. CUDA backend does not work accurately. Nevertheless, good luck!

  • dos2unix helped me run my script I did on Linux. Thank you! – lekant Jan 13 '20 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.