1

I am creating a shell file on the fly containing following commands

 #!/bin/sh
    gcc -Wall -c *.c
    gcc -shared -o libr.so *.o

When I cd to that location and run the shell script using this command sh fun.sh, I am getting following error

sh fun.sh : No such file or directory 
gcc: fatal error: no input files
compilation terminated.

Typing these commands one by one in the linux does the work but shell script is not working. Kindly help me out with this

10
  • 2
    Does fun.sh have DOS-style (CRLF) endings? Check with file fun.sh Commented Aug 10, 2022 at 17:18
  • Are there any .c files in that directory? Commented Aug 10, 2022 at 17:20
  • Hi Bib Yes there are two .c files Commented Aug 10, 2022 at 17:21
  • 2
    Could you please make sure that the full error message is correctly represented in the question. The error message is formatted strangely, with spaces around : and with the full command at the start. It looks like the shell is saying it can't find gcc, but then gcc is saying that it didn't get any input files (formatted in a way that only makes sense if nullglob was set in the bash shell, which, AFAICS, it is not). Commented Aug 10, 2022 at 17:26
  • 1
    this really doesn't look like the verbatim copy and pasted error message including line breaks. With the incomplete information given, it's very hard to help you! Commented Aug 10, 2022 at 18:47

1 Answer 1

-1

I know the mistake I was making. I was creating this shell script on the fly. I created a template script.sh and created a MATLAB function to automate the process so that content of the shell script gets added dynamically. The mistake I was doing, I created the template script in Windows, and uploaded it on the network. The template script was written in Windows, though I was generating this shell script on the Linux. When I did dos2inux, it worked. Now when I am writing template file in Linux, and generating the script, it is working fine. Thanks everyone for you answers.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.