I want to use bash commands in Makefile along with MATLAB scripts. Currently when i put a simple bash command in Makefile and run that target, I get error

/bin/bash: ./test1: No such file or directory

I have used a simple bash command

bash -c "cd ~/Desktop/r4/saturatedrate/iperf_s"; echo "I'm in some_dir"; ./test1; echo "is it working"

I have also put SHELL := /bin/bashin beginning of make file as suggested by enter link description here

I am using Mac OsX

  • 1
    Give a look to some tutorial on the net about how to create a makefile. E.g. here. Take a working makefile and modify it. Usually it's more cosy. BTW post your whole makefile file so it will be possible to check it.
    – Hastur
    Sep 6, 2015 at 9:35

1 Answer 1


The semi-colon will terminate a bash command. So bash -c "cd ~/Desktop/r4/saturatedrate/iperf_s"; starts a bash shell and does the cd command then exits. Then the echo command and then the test1 command - but test1 does not exist in the current directory. Remember the shell command that issued the cd command has exited.

This make command should call test1:

    bash -c "cd ~/Desktop/r4/saturatedrate/iperf_s/test1"; 
  • when i try this command test1 which is placed in 'code'~/Desktop/r4/saturatedrate/iperf_s is run the current directory from where the command is run. I want the test1 to run in this directory "~/Desktop/r4/saturatedrate/iperf_s/"
    – Umar
    Sep 6, 2015 at 19:07
  • 1
    bash -c "cd ~/Desktop/r4/saturatedrate/iperf_s && ./test1" is working @suspectus, Thank you so much
    – Umar
    Sep 6, 2015 at 19:21
  • @Umar - Glad to hear you have it working now.
    – suspectus
    Sep 6, 2015 at 19:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .