LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   "!#/bin/bash: No such file or directory"? When running a script (https://www.linuxquestions.org/questions/linux-newbie-8/bin-bash-no-such-file-or-directory-when-running-a-script-800881/)

C_Blade 04-08-2010 05:32 PM

"!#/bin/bash: No such file or directory"? When running a script
 
Hi so I'm a new Linux user and I was programming a script for class, which is a pretty simple script. I have already made it executable and when I call the program I type ./myscript so that isn't the problem. For some reason it has a problem with the way I typed my first line I believe. My script simply begins, right off the bat, with a

#!/bin/bash



Anyone know what the problem is? Any help would be extremely appreciated :(

Tinkster 04-08-2010 05:38 PM

Hi, welcome to LQ!

Edited in windows? You may have a trailing '^M'


Cheers,
Tink

C_Blade 04-08-2010 05:55 PM

Not exactly, I have a VirtualBox running Ubuntu, so the file has never been edited in any other format. Could I be missing a certain file for bin/bash? That wouldn't make any sense. But this command is required for scripts to run so I'm feeling a little hopeless at this point.

Tinkster 04-08-2010 05:57 PM

What's the output of
Code:

which bash
and what's your current path
Code:

echo $PATH
?

C_Blade 04-08-2010 06:10 PM

which bash:
Code:

/bin/bash
echo $PATH:
Code:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

Tinkster 04-08-2010 06:11 PM

Ok, that looks normal ....

Next question:

In your posts body you have
Code:

#!/bin/bash
In the subject line it says:
Code:

!#/bin/bash
Which is in your script?

C_Blade 04-08-2010 06:17 PM

Okay, just know that this is the first script I wrote, and since I haven't been able to run it at all, I haven't got a chance to debug or figure out what was wrong in it. I think the first line is the most crucial problem =/

Code:

#!/bin/bash
while [ $# gt -1 ]
  if [ -f $1 ]
  then
      print STDERR "Error: first file exists"
  else
      print STDOUT "$1"
      print STDOUT "$2"
      shift
    fi
done
exit


Tinkster 04-08-2010 06:21 PM

Except for the missing do under while and the fact that
"print" is not a bash command it looks OK.

Should work, is what they say (well, and the tests
need some honing).

C_Blade 04-08-2010 06:31 PM

Yeah, when I call the program, it just says gives me:

Code:

./combine: line 1: !#bin/bash/: No such file or directory
Yeah so I can't figure it out, I'm guessing you haven't seen anything like this before either? Maybe I'll try to find a Linux computer on campus and try it there.

Tinkster 04-08-2010 06:37 PM

Quote:

Originally Posted by C_Blade (Post 3929211)
Yeah, when I call the program, it just says gives me:

Code:

./combine: line 1: !#bin/bash/: No such file or directory
Yeah so I can't figure it out, I'm guessing you haven't seen anything like this before either? Maybe I'll try to find a Linux computer on campus and try it there.


Now you produced a THIRD variant, which is wrong (similar
to the one in the subject):

It's
Code:

#!/bin/bash
not
Code:

#!bin/bash

C_Blade 04-08-2010 07:04 PM

Ohhhhhh man... I made some terribly stupid mistakes with this code. I looked at examples over and over again and I swore I had everything in the right place.

Thank you so much Tinkster!!!! :)

Tinkster 04-08-2010 07:14 PM

Most welcome, and:
No worries - we all have those days ;}

grail 04-08-2010 10:15 PM

Good to see your solution finally came about, please remember to mark as SOLVED.


All times are GMT -5. The time now is 03:27 PM.